fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerFix section names in suggested "help" commands4ffa06fb7

master
4.7 KiB140 linesraw
1#RUN: fish=%fish %fish %s
2
3# A $status used as a command should not impact the location of other errors.
4echo 'echo foo | exec grep # this exec is not allowed!
5
6$status
7
8 # The error might be found here!' | $fish 2>| string replace -r '(.*)' '<$1>'
9
10# CHECK: <fish: The 'exec' command can not be used in a pipeline>
11# CHECK: <echo foo | exec grep # this exec is not allowed!>
12# CHECK: <           ^~~~~~~~^>
13
14echo 'true | time false' | $fish 2>| string replace -r '(.*)' '<$1>'
15# CHECK: <fish: The 'time' command may only be at the beginning of a pipeline>
16# CHECK: <true | time false>
17# CHECK: <       ^~~~~~~~~^>
18
19
20echo '
21
22FOO=BAR (true one)
23(true two)
24
25# more things
26' | $fish 2>| string replace -r '(.*)' '<$1>'
27
28# CHECK: <fish: command substitutions not allowed in command position. Try var=(your-cmd) $var ...>
29# CHECK: <FOO=BAR (true one)>
30# CHECK: <        ^~~~~~~~~^>
31
32$fish -c 'echo "unfinished "(subshell' 2>| string replace -r '.*' '<$0>'
33# CHECK: <fish: Unexpected end of string, expecting ')'>
34# CHECK: <echo "unfinished "(subshell>
35# CHECK: <                  ^>
36
37$fish -c 'echo "unfinished "$(subshell' 2>| string replace -r '.*' '<$0>'
38# CHECK: <fish: Unexpected end of string, expecting ')'>
39# CHECK: <echo "unfinished "$(subshell>
40# CHECK: <                   ^>
41
42$fish -c 'echo "ok $(echo still ok)syntax error: \x"' 2>| string replace -r '.*' '<$0>'
43# CHECK: <fish: Invalid token '"ok $(echo still ok)syntax error: \x"'>
44# CHECK: <echo "ok $(echo still ok)syntax error: \x">
45# CHECK: <                         ^~~~~~~~~~~~~~~~^>
46
47echo "function this_should_be_an_error" >$TMPDIR/this_should_be_an_error.fish
48$fish -c "set -g fish_function_path $(string escape $TMPDIR); this_should_be_an_error"
49# CHECKERR: ~/temp/this_should_be_an_error.fish (line 1): Missing end to balance this function definition
50# CHECKERR: function this_should_be_an_error
51# CHECKERR: ^~~~~~~^
52# CHECKERR: from sourcing file ~/temp/this_should_be_an_error.fish
53# CHECKERR: source: Error while reading file '{{.*}}/this_should_be_an_error.fish'
54# CHECKERR: fish: Unknown command: this_should_be_an_error
55# CHECKERR: fish:
56# CHECKERR: set -g fish_function_path {{.*}}; this_should_be_an_error
57# CHECKERR:                                   ^~~~~~~~~~~~~~~~~~~~~~^
58
59$fish -c 'echo {$}'
60# CHECKERR: fish: Expected a variable name after this $.
61# CHECKERR: echo {$}
62# CHECKERR: ^
63
64$fish -c 'echo {$,}'
65# CHECKERR: fish: Expected a variable name after this $.
66# CHECKERR: echo {$,}
67# CHECKERR: ^
68
69echo "bind -M" | $fish
70# CHECKERR: bind: -M: option requires an argument
71# CHECKERR: Standard input (line 1):
72# CHECKERR: bind -M
73# CHECKERR: ^
74# CHECKERR: (Type 'help bind' for related documentation)
75
76$fish -c 'if -e; end'
77# CHECKERR: fish: Unknown command: -e
78# CHECKERR: fish:
79# CHECKERR: if -e; end
80# CHECKERR:    ^^
81
82$fish -c 'begin --notanoption; end'
83# CHECKERR: fish: Unknown command: --notanoption
84# CHECKERR: fish:
85# CHECKERR: begin --notanoption; end
86# CHECKERR:       ^~~~~~~~~~~~^
87
88$fish -c 'begin --help'
89# CHECKERR: Documentation for begin
90
91$fish -c 'echo (for status in foo; end)'
92# CHECKERR: fish: for: status: cannot overwrite read-only variable
93# CHECKERR: for status in foo; end
94# CHECKERR: ^~~~~^
95# CHECKERR: in command substitution
96# CHECKERR: fish: Invalid arguments
97# CHECKERR: echo (for status in foo; end)
98# CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~~^
99
100$fish -c 'echo (echo <&foo)'
101# CHECKERR: fish: Requested redirection to 'foo', which is not a valid file descriptor
102# CHECKERR: echo <&foo
103# CHECKERR: ^~~~^
104# CHECKERR: in command substitution
105# CHECKERR: fish: Invalid arguments
106# CHECKERR: echo (echo <&foo)
107# CHECKERR: ^~~~~~~~~~~^
108
109
110$fish -c 'echo (time echo foo &)'
111# CHECKERR: fish: 'time' is not supported for background jobs. Consider using 'command time'.
112# CHECKERR: time echo foo &
113# CHECKERR: ^~~~~~~~~~~~~~^
114# CHECKERR: in command substitution
115# CHECKERR: fish: Invalid arguments
116# CHECKERR: echo (time echo foo &)
117# CHECKERR: ^~~~~~~~~~~~~~~~^
118
119$fish -c 'time begin; end &'
120# CHECKERR: fish: 'time' is not supported for background jobs. Consider using 'command time'.
121# CHECKERR: time begin; end &
122# CHECKERR: ^~~~~~~~~~~~~~~~^
123
124$fish -c 'echo (set -l foo 1 2 3; for $foo in foo; end)'
125# CHECKERR: fish: Unable to expand variable name ''
126# CHECKERR: set -l foo 1 2 3; for $foo in foo; end
127# CHECKERR: ^~~^
128# CHECKERR: in command substitution
129# CHECKERR: fish: Expansion error
130# CHECKERR: echo (set -l foo 1 2 3; for $foo in foo; end)
131# CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
132
133$fish -c 'echo (echo *nosuchname*)'
134# CHECKERR: fish: No matches for wildcard '*nosuchname*'. See `help language#wildcards-globbing`.
135# CHECKERR: echo *nosuchname*
136# CHECKERR: ^~~~~~~~~~~^
137# CHECKERR: in command substitution
138# CHECKERR: fish: Unmatched wildcard
139# CHECKERR: echo (echo *nosuchname*)
140# CHECKERR: ^~~~~~~~~~~~~~~~~~^