mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-29 16:51:15 -03:00
ast: Require --help to parse more keywords as decorated statement (#10000)
This makes it so
```fish
if -e foo
# do something
end
```
complains about `-e` not being a command instead of `end` being used
outside of an if-block.
That means both that `-e` could now be used as a command name (it
already can outside of `if`!) *and* that we get a better error!
The only way to get `if` to be a decorated statement now is to use `if
-h` or `if --help` specifically (with a literal option).
The same goes for switch, while and begin.
It would be possible, alternatively, to disallow `if -e` and point
towards using `test` instead, but the "unknown command" message should
already point towards using `test` more than pointing at the
"end" (that might be quite far away).
This commit is contained in:
@@ -73,3 +73,19 @@ echo "bind -M" | $fish
|
||||
# CHECKERR: ^
|
||||
# CHECKERR: (Type 'help bind' for related documentation)
|
||||
|
||||
$fish -c 'if -e; end'
|
||||
# CHECKERR: fish: Unknown command: -e
|
||||
# CHECKERR: fish:
|
||||
# CHECKERR: if -e; end
|
||||
# CHECKERR: ^^
|
||||
|
||||
$fish -c 'begin --notanoption; end'
|
||||
# CHECKERR: fish: Unknown command: --notanoption
|
||||
# CHECKERR: fish:
|
||||
# CHECKERR: begin --notanoption; end
|
||||
# CHECKERR: ^~~~~~~~~~~~^
|
||||
|
||||
$fish -c 'begin --help'
|
||||
# CHECKERR: fish: begin: missing man page
|
||||
# CHECKERR: Documentation may not be installed.
|
||||
# CHECKERR: `help begin` will show an online version
|
||||
|
||||
Reference in New Issue
Block a user