mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-30 22:34:29 +08:00
8d7416048d
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.
51 lines
904 B
Fish
51 lines
904 B
Fish
#RUN: %fish %s
|
|
|
|
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
|
|
echo success1
|
|
end
|
|
# CHECK: success1
|
|
if false; and false
|
|
echo failure1
|
|
end
|
|
while false; and false; or true
|
|
echo success2
|
|
break
|
|
end
|
|
# CHECK: success2
|
|
while false; or begin
|
|
false; or true
|
|
end
|
|
echo success3
|
|
break
|
|
end
|
|
# CHECK: success3
|
|
if false
|
|
else if false; and true
|
|
else if false; and false
|
|
else if false; or true
|
|
echo success4
|
|
end
|
|
# CHECK: success4
|
|
if false
|
|
else if false; and true
|
|
else if false; or false
|
|
else if false
|
|
echo "failure 4"
|
|
end
|
|
if false; or true | false
|
|
echo failure5
|
|
end
|