elvish icon indicating copy to clipboard operation
elvish copied to clipboard

Parse braced lists like ordinary lists

Open hanche opened this issue 4 years ago • 3 comments

Braced lists should be parsed exactly like regular lists – apart from the delimiters, of course, and also apart from the fact a braced list cannot begin with white space, as that would be parsed as a lambda.

In particular, the comma should not be used as a separator.

I also find these behaviours surprising, and hence undesirable:

⬥ put {} a{} {}b {c }
⮕ ''
⮕ a
⮕ b
⮕ c
⮕ ''

The only output I would expect from that one, is the lone c.

If the user wants an empty string, let them write an explicit ''.

(This has been discussed on Telegram recently.)

hanche avatar Apr 30 '20 10:04 hanche

Please note the very confusing bash behavior:

bash-5.0$ echo {}z
{}z
bash-5.0$ echo {a b}z
{a b}z
bash-5.0$ echo {a,b}z
az bz
bash-5.0$ echo { }z
{ }z
bash-5.0$ echo {,}z
z z

I feel this is an area where there should be almost zero consideration given to how shells like bash, ksh, and zsh handle this syntax. Primarily because their behavior is idiosyncratic.

Note that the fish shell, which is not a POSIX compliant shell, handles the first example, echo {}z, differently than bash/ksh/zsh. Fish outputs "z" which seems to me to be far more sensible. It also matches the current Elvish behavior.

krader1961 avatar May 03 '20 03:05 krader1961

All else being equal, it would be nice if

mv file{,.bak}

still worked.

mikelward avatar Jul 15 '23 19:07 mikelward

mv file{'' .bak}

Doesn't seem too bad if you need to remove commas as separators. But would require updating the docs, and announcing the breaking change.

mikelward avatar Jul 15 '23 19:07 mikelward