mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-20 10:31:16 -03:00
Support help argument in "{ -h"
Unlike other builtins, "{" is a separate token, not a keyword-string
token.
Allow the left brace token as command string; produce it when parsing
"{ -h"/"{ --help" (and nowhere else). By using a decorated statement,
we reuse logic for redirections etc.
Other syntax elements like "and" are in the builtin list, which
- adds highlighting logic
- adds it to "builtin --names"
- makes it runnable as builtin
(e.g. "builtin '{'" would hypothetically print the man page)
These don't seem very important (highlighting for '{' needs to match
'}' anyway).
Additionally, making it a real builtin would mean that we'd need to
deactivate a few places that unescape "{" to BRACE_BEGIN.
Let's not add it to the built in list. Instead, simply synthesize
builtin_generic in the right spot.
I'm assuming we want "{ -h" to print help, but '"{" -h' to run an
external command, since the latter is historical behavior. This works
naturally with the above fake builtin approach which never tries to
unescape the left brace.
This commit is contained in:
@@ -187,10 +187,26 @@ PATH= "{"
|
||||
# CHECKERR: PATH= "{"
|
||||
# CHECKERR: ^~^
|
||||
|
||||
$fish -c '{ -h'
|
||||
# CHECKERR: fish: '{': missing man page
|
||||
# CHECKERR: Documentation may not be installed.
|
||||
# CHECKERR: `help '{'` will show an online version
|
||||
|
||||
PATH= "{" -h
|
||||
# CHECKERR: fish: Unknown command: '{'
|
||||
# CHECKERR: {{.*}}/braces.fish (line {{\d+}}):
|
||||
# CHECKERR: PATH= "{" -h
|
||||
# CHECKERR: ^~^
|
||||
|
||||
$fish -c 'builtin {'
|
||||
# CHECKERR: fish: Expected end of the statement, but found a '{'
|
||||
# CHECKERR: builtin {
|
||||
# CHECKERR: ^
|
||||
# CHECKERR: ^
|
||||
|
||||
$fish -c 'builtin "{"'
|
||||
# CHECKERR: fish: Unknown builtin '"{"'
|
||||
# CHECKERR: builtin "{"
|
||||
# CHECKERR: ^~~~~~~~~~^
|
||||
|
||||
$fish -c 'command {'
|
||||
# CHECKERR: fish: Expected end of the statement, but found a '{'
|
||||
|
||||
@@ -482,6 +482,9 @@ level 2 } }
|
||||
# CHECK: {{^ level 2$}}
|
||||
# CHECK: {{^ \}$}}
|
||||
# CHECK: {{^\}$}}
|
||||
|
||||
echo '{ -h'
|
||||
# CHECK: { -h
|
||||
} | $fish_indent
|
||||
|
||||
echo 'multiline-\\
|
||||
|
||||
Reference in New Issue
Block a user