elvish
elvish copied to clipboard
treat '#' as a bareword if it's after non-whitespace character
Nix takes strings with '#' as an argument
# sudo nixos-rebuild switch --flake .#root --impure # not work
sudo nixos-rebuild switch --flake '.#root' --impure
Can we allow '#' as a bareword if it's after non-whitespace character?
I haven't seen this pattern other than nix, but hope not it requires big changes in the specification.
λ bash -c 'echo 3#4'
3#4
λ fish -c 'echo 3#4'
3#4
I think this proposal is a bad idea. An analogous situation involves the question-mark, which is common in URLs. Introducing special-cases as proposed here greatly increases the cognitive load for the benefit of very few users and only a tiny fraction of the commands they execute. Doing this means you now have to document, and people have to remember, that echo a#b
is quite different from echo a #b
.
I also don't think specification should change only because of single command. Hope anyone find some other cases or reasons to justify changes.
Please note, @aca, that the list of similar examples is huge. Consider the git CLI
. That document doesn't cover the most commonly used meta-character in Git strings, the tilde, but you get the idea. Complicating the rules for what constitutes an Elvish bareword, makes it harder for people to interpret any given block of code. It's bad enough that ~
and =
are already special-cased. I don't think we want to introduce more special-case rules for such characters.