mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 03:51:14 -03:00
Don't skip caret for some errors
This checked specifically for "| and" and "a=b" and then just gave the
error without a caret at all.
E.g. for a /tmp/broken.fish that contains
```fish
echo foo
echo foo | and cat
```
This would print:
```
/tmp/broken.fish (line 3): The 'and' command can not be used in a pipeline
warning: Error while reading file /tmp/broken.fish
```
without any indication other than the line number as to the location
of the error.
Now we do
```
/tmp/broken.fish (line 3): The 'and' command can not be used in a pipeline
echo foo | and cat
^~^
warning: Error while reading file /tmp/broken.fish
```
Another nice one:
```
fish --no-config -c 'echo notprinted; echo foo; a=b'
```
failed to give the error message!
(Note: Is it really a "warning" if we failed to read the one file we
wer told to?)
We should check if we should either centralize these error messages
completely, or always pass them and remove this "code" system, because
it's only used in some cases.
This commit is contained in:
@@ -4,9 +4,13 @@ set -xl LANG C # uniform quotes
|
||||
|
||||
eval 'true | and'
|
||||
# CHECKERR: {{.*}}: The 'and' command can not be used in a pipeline
|
||||
# CHECKERR: true | and
|
||||
# CHECKERR: ^~^
|
||||
|
||||
eval 'true | or'
|
||||
# CHECKERR: {{.*}}: The 'or' command can not be used in a pipeline
|
||||
# CHECKERR: true | or
|
||||
# CHECKERR: ^^
|
||||
|
||||
# Verify and/or behavior with if and while
|
||||
if false; or true
|
||||
|
||||
@@ -94,3 +94,14 @@ $fish --no-config -c 'echo $$ oh no syntax error' -c 'echo this works'
|
||||
$fish --no-config .
|
||||
# CHECKERR: error: Unable to read input file: Is a directory
|
||||
# CHECKERR: warning: Error while reading file .
|
||||
|
||||
$fish --no-config -c 'echo notprinted; echo foo; a=b'
|
||||
# CHECKERR: fish: Unsupported use of '='. In fish, please use 'set a b'.
|
||||
# CHECKERR: echo notprinted; echo foo; a=b
|
||||
# CHECKERR: ^~^
|
||||
|
||||
$fish --no-config -c 'echo notprinted | and true'
|
||||
# CHECKERR: fish: The 'and' command can not be used in a pipeline
|
||||
# CHECKERR: echo notprinted | and true
|
||||
# CHECKERR: ^~^
|
||||
|
||||
|
||||
@@ -87,10 +87,16 @@ complete -C'a=b envxalias '
|
||||
# Eval invalid grammar to allow fish to parse this file
|
||||
eval 'a=(echo b)'
|
||||
# CHECKERR: {{.*}}: Unsupported use of '='. In fish, please use 'set a (echo b)'.
|
||||
# CHECKERR: a=(echo b)
|
||||
# CHECKERR: ^~~~~~~~~^
|
||||
eval ': | a=b'
|
||||
# CHECKERR: {{.*}}: Unsupported use of '='. In fish, please use 'set a b'.
|
||||
# CHECKERR: : | a=b
|
||||
# CHECKERR: ^~^
|
||||
eval 'not a=b'
|
||||
# CHECKERR: {{.*}}: Unsupported use of '='. In fish, please use 'set a b'.
|
||||
# CHECKERR: not a=b
|
||||
# CHECKERR: ^~^
|
||||
|
||||
complete -c foo -xa '$a'
|
||||
a=b complete -C'foo '
|
||||
|
||||
Reference in New Issue
Block a user