mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 21:21:15 -03:00
Forbid subcommand keywords in variables-as-commands (#10249)
This stops you from doing e.g. ```fish set pager command less echo foo | $pager ``` Currently, it would run the command *builtin*, which can only do `--search` and similar, and would most likely end up printing its own help. That means it very very likely won't work, and the code is misguided - it is trying to defeat function resolution in a way that won't do what the author wants it to. The alternative would be to make the command *builtin* execute the command, *but* 1. That would require rearchitecting and rewriting a bunch of it and the parser 2. It would be a large footgun, in that `set EDITOR command foo` will only ever work inside fish, but $EDITOR is also used outside. I don't want to add a feature that we would immediately have to discourage.
This commit is contained in:
@@ -334,3 +334,9 @@ printf '<%s>\n' ($fish -c 'echo "$abc["' 2>&1)
|
||||
#CHECK: <fish: Invalid index value>
|
||||
#CHECK: <echo "$abc[">
|
||||
#CHECK: < ^>
|
||||
|
||||
set -l pager command less
|
||||
echo foo | $pager
|
||||
#CHECKERR: checks/expansion.fish (line 339): The expanded command is a keyword.
|
||||
#CHECKERR: echo foo | $pager
|
||||
#CHECKERR: ^~~~~^
|
||||
|
||||
Reference in New Issue
Block a user