Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behaviour in brace expansion #3004

Closed
andgra2 opened this issue May 7, 2016 · 3 comments
Closed

Inconsistent behaviour in brace expansion #3004

andgra2 opened this issue May 7, 2016 · 3 comments

Comments

@andgra2
Copy link

andgra2 commented May 7, 2016

Brace expansion seems a bit inconsistent in its behaviour, see below. The documentation is also not so clear about this case.

Reproduction Steps:

  1. Run: begin; set -l arr a b; echo x{$arr,c}y; end
  2. Run: begin; set -l arr a b; echo x{{a,b},c}y; end

Expected behavior:

I expect 1. to give the same output as 2, ie: xay xby xcy.

That's the same output as echo x{a,b,c}y (ie things (arrays or other brace expressions) inside a brace expression should be unioned togheter when expanding).

This for consistency and simplicity reasons. I expect $arr and {a,b} to work in the same way in cases when they are both expanded.

Observed behavior:

  1. Outputs: xay xcy xby xcy
  2. Outputs: xay xby xcy

Additional information:


Fish version: fish, version 2.2.0-876-g1c6f6df
Operating system: ubuntu 64-bit, compiled fish from github source

Terminal or terminal emulator: The builtin terminal emulator of neovim.

@krader1961
Copy link
Contributor

Those examples are just variations of the problem reported in issue #3002.

@andgra2
Copy link
Author

andgra2 commented May 7, 2016

I think this is quite different than #3002.

Here we have only one , in the outermost brace expression, but the problem in #3002 needs two , in order to reproduce.

jakwings added other examples in #3002, but I think those examples are more related to this issue (#3004).

Because of this I think this issue should be reopened. However it doesn't matter so much, I can check if this issue #3004 is solved when #3002 is solved, but I'm not sure that may be the case.

@ghost
Copy link

ghost commented May 7, 2016

fish seems like doing echo x{$arr,c}y this way:

Step 1: join(x, join&merge([a, b], c), y)
Step 2: join(x, {a, c, b, c}, y)
Step 3: join(x, a, y)  join(x, c, y)  join(x, b, y)  join(x, c, y)
Result: xay xcy xby xcy

As to echo x{{a,b},c}y, I imagine fish is doing this:

Step 1: join(x, merge({a, b}, c), y)
Step 2: join(x, {a, b, c}, y)
Step 3: join(x, a, y)  join(x, b, y)  join(x, c, y)
Result: xay xby xcy

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants