elvish
elvish copied to clipboard
Parse braced lists like ordinary lists
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.)
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.
All else being equal, it would be nice if
mv file{,.bak}
still worked.
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.