Changeset View
Changeset View
Standalone View
Standalone View
autotests/input/highlight.fish
- This file was added.
1 | ### Comments | ||||
---|---|---|---|---|---|
2 | # TODO | ||||
3 | # BEGIN | ||||
4 | # fg sfg sfh sft | ||||
5 | # END | ||||
6 | # | ||||
7 | # text in (parenthesis) is ok, (even | ||||
8 | # over several lines) | ||||
9 | # escaped \) and \( are ok | ||||
10 | # an unbalanced single ) is not ok | ||||
11 | # This is due to fish comment handling in command substitutions | ||||
12 | # which cannot reasonably handled by kate syntax highlighting | ||||
13 | | ||||
14 | | ||||
15 | ### Commands and paths | ||||
16 | ls -l |sort | ||||
17 | ls -1 | ||||
18 | /usr/bin/ls -l /usr/local/test/ -xyz # option as indicator of CommandArgs context | ||||
19 | ./bin/ls -l /usr/abc**/tes?/lkhlk -xyz # tabulator as separator | ||||
20 | ../bin/ls -l /usr/abc**/tes?/lkhlk | ||||
21 | ~/bin/ls -l ../usr/lo\ cal/test | ||||
22 | ~user/bin/ls -l /usr/{local,remote}}/test|cat # show error | ||||
23 | /usr/bin/../lib/ls -l /usr/local/test.???|cat | ||||
24 | /usr/bin\ sdfg/ls -l /usr/local/test.* | ||||
25 | usr/bin/other -l ~user/local/test | ||||
26 | \ usr/bin/other -l ~user/local/test | ||||
27 | /usr/bin/lsother | ||||
28 | ../test/root/bin/fish -c "echo $t8" | ||||
29 | test/root/bin/fish -c "echo $t8" | ||||
30 | u?r/bin/ls | ||||
31 | usr/b?n/ls | ||||
32 | u*ls # doesn't work, but ok | ||||
33 | "ls" /tmp/testtest # Quotes in commands are expanded | ||||
34 | /us"r/bin"/xy/ls | ||||
35 | abcd$a # show error | ||||
36 | other) abc # show error | ||||
37 | <other abc # show error | ||||
38 | other> abc # ok | ||||
39 | oth>er abc # ok | ||||
40 | ot(her) abc # show error | ||||
41 | | ||||
42 | ls /ho"me/te"st'user'/abc$dir[3]/ab(echo cdefg)cd/xyz | ||||
43 | cat\ alog -abc | ||||
44 | ls path_not_detected | ||||
45 | ls * no_path | ||||
46 | ls *path_detected | ||||
47 | ls/ | ||||
48 | ls;echo xy | ||||
49 | flex++ | ||||
50 | | ||||
51 | #specials | ||||
52 | command -s ls | ||||
53 | builtin --names jobs | ||||
54 | exec bash | ||||
55 | exec $test | ||||
56 | set -e i[-1] | ||||
57 | set test1[-1..1] $test; echo $test1 | ||||
58 | set test1[1..$n] $test; echo $test1 | ||||
59 | set test1[$n..1] $test; echo $test1 | ||||
60 | set test1[2..4 -2..-4] $test1[4..2 -4..-2]; echo $test1 | ||||
61 | set page_url http://fishshell.com/docs/$version_string/$fish_help_page # ??? | ||||
62 | string split . example.com | ||||
63 | set b (string repeat -n 512 x) | ||||
64 | | ||||
65 | read -gi test # ok | ||||
66 | read -gi $test | ||||
67 | read -gi "test" | ||||
68 | read -gi (echo test) | ||||
69 | | ||||
70 | set x (string split --max 1 --right / (status current-filename) #Comment test) | ||||
71 | set test (exec $cmd) | ||||
72 | | ||||
73 | # direct path | ||||
74 | test -d $tmpldir/resources | ||||
75 | | ||||
76 | ### Options | ||||
77 | cat -l /usr/local/test>logfile | ||||
78 | ls --longopt=/test | ||||
79 | ls -l"kasdflakjs" -r/usr/test -x../test/../bla -z~xyz/hello | ||||
80 | | ||||
81 | ### Arguments | ||||
82 | echo abc"def"ghi | ||||
83 | echo abc/def | ||||
84 | echo abc[de] | ||||
85 | echo abc(echo def)ghi | ||||
86 | echo abc{de,f}ghi | ||||
87 | | ||||
88 | # Path Detection | ||||
89 | cd abc*efghi # fish assumes * is glob -> path | ||||
90 | cd abc?efghi | ||||
91 | cd .. | ||||
92 | cd .. # | ||||
93 | cd . | ||||
94 | cd . # | ||||
95 | cd ~ | ||||
96 | cd ~abc/abc/*.txt | ||||
97 | cd ./abc | ||||
98 | cd ../abc | ||||
99 | cd \ abc/tmp\ .txt | ||||
100 | | ||||
101 | test .. abc | ||||
102 | | ||||
103 | ### Escapes | ||||
104 | touch a\?bc\[\]ax\~dsf\#gsd\af\(\)dg\?sd\ fg\bhh\%j\$k\\l\?sed\*jk\>hj\<hou\&h\;hgkj\^kj\"kjh\'jhg | ||||
105 | touch sdf\xa5lh\Xb7kll\157j\158hk\ua47bz\U123b5678fs\cxzdfga | ||||
106 | | ||||
107 | touch "a\?bc\[\]a" # no escaping in Quotes | ||||
108 | touch fgh\y1 # \y is no escape sequence in fish, show it as normal text like fish itself | ||||
109 | | ||||
110 | ### Builtins | ||||
111 | . hallo | ||||
112 | source hallo | ||||
113 | eval ls . /tmp | ||||
114 | eval ls .../tmp | ||||
115 | eval $var | ||||
116 | eval abc | ||||
117 | eval {l,a}s # lists ./as. colours not ok, but we cut here | ||||
118 | eval "echo bla" | ||||
119 | | ||||
120 | history merge | ||||
121 | | ||||
122 | true ;ls | ||||
123 | echo (true) | ||||
124 | echo (true #comment) | ||||
125 | echo (true>>xyz/abc) | ||||
126 | true -error # show error | ||||
127 | pwd > abc | ||||
128 | | ||||
129 | command -s ls;cat test | ||||
130 | builtin -n;builtin echo | ||||
131 | | ||||
132 | complete -c myprog -s o -l output -a "yes no" | ||||
133 | builtin jobs | ||||
134 | | ||||
135 | math -s0 10.0 / 6.0 | ||||
136 | | ||||
137 | #special keywords as directory names: | ||||
138 | /usr/function/testtest /usr/function/testtest | ||||
139 | /usr/for/testtest /usr/for/testtest | ||||
140 | /usr/begin/testtest /usr/begin/testtest | ||||
141 | /usr/switch/testtest /usr/switch/testtest | ||||
142 | /usr/if/testtest /usr/if/testtest | ||||
143 | /usr/while/testtest /usr/while/testtest | ||||
144 | /usr/command/testtest /usr/command/testtest | ||||
145 | /usr/builtin/testtest /usr/builtin/testtest | ||||
146 | /usr/eval/testtest /usr/eval/testtest | ||||
147 | /usr/exec/testtest /usr/exec/testtest | ||||
148 | /usr/set/testtest /usr/set/testtest | ||||
149 | /usr/test/testtest /usr/test/testtest | ||||
150 | | ||||
151 | ### test | ||||
152 | test NUM1 -eq NUM2 | ||||
153 | test -f /tmp/abc -a -e /tmp/def;cat /tmp/abc; | ||||
154 | | ||||
155 | if test \( -f /foo -o -f /bar \) -a \( -f /baz -o -f /bat \) | ||||
156 | echo Success. | ||||
157 | end | ||||
158 | | ||||
159 | [ 25 -eq $NUM2 ] | ||||
160 | [ "abc" = "$STRING2" ] | ||||
161 | | ||||
162 | if [ ! \(STRING1 != STRING2\) ];ls;end | ||||
163 | if [ -f abc ]# show error | ||||
164 | end | ||||
165 | if [ -f abc ] # ok | ||||
166 | end | ||||
167 | | ||||
168 | if [ ! \(STRING1 != STRING2\) ] ls;end # show error | ||||
169 | if [ "abc" != "def" ] # hallo | ||||
170 | echo x;end | ||||
171 | | ||||
172 | ### Redirections | ||||
173 | ls < SOURCE_FILE # stdin | ||||
174 | ls > DESTINATION # stdout | ||||
175 | ls ^ DESTINATION # stderr | ||||
176 | ls >> DESTINATION_FILE # append | ||||
177 | ls ^^ DESTINATION_FILE # append | ||||
178 | ls >? DESTINATION # noclobber | ||||
179 | ls ^? DESTINATION | ||||
180 | | ||||
181 | ls ^? ~ | ||||
182 | ls ^? ~testuser/abc | ||||
183 | ls ^?/DESTINATION | ||||
184 | ls ^?#DESTINATION # show error | ||||
185 | | ||||
186 | ls > $abc[5] | ||||
187 | ls >"abc"/defg$v/xyz | ||||
188 | | ||||
189 | ls >& # show error | ||||
190 | ls > &1 # show error | ||||
191 | ls abc>&25 xyz /tmp/xyz $abc | ||||
192 | ls /tmp/tst>&25? # show error | ||||
193 | ls /tmp/tst>&25 ? # ok | ||||
194 | ls 3>&- xyz | ||||
195 | ls 1<DESTINATION | ||||
196 | echo Hello > all_output.txt ^&1 xyz | ||||
197 | ls 2>&-;echo end | ||||
198 | ls xyz 2>|cat | ||||
199 | | ||||
200 | ls>x | ||||
201 | abs>x | ||||
202 | /bin/ls>x | ||||
203 | /bin/abs>x | ||||
204 | | ||||
205 | ### Quoting | ||||
206 | echo 'abcdefg' | ||||
207 | echo 'abc\'de\\fg' | ||||
208 | echo 'abc\defg' | ||||
209 | | ||||
210 | echo "1\"23\$45\\6" | ||||
211 | echo '1\"23\$45\\6' | ||||
212 | echo ' | ||||
213 | hallo | ||||
214 | ' | ||||
215 | echo "$i: '$$name[1][$i]'" | ||||
216 | | ||||
217 | | ||||
218 | ### Piping, Pipelines and background jobs | ||||
219 | ls -l /tmp/hello 1<DEST| sort | ||||
220 | comand_1;command_2 | ||||
221 | comand_1 ;command_2 | ||||
222 | ls;ls | ||||
223 | run_long_job & ls # yes & is a command sequencing operator like | and ; | ||||
224 | cat foo.txt | head | ||||
225 | make fish 2>| less #show error | ||||
226 | | ||||
227 | ### Variable Expansion | ||||
228 | echo $PATH | ||||
229 | echo $PATH[1..3] | ||||
230 | echo $PATH[-1..3 5 9..15] | ||||
231 | echo $PATH[$n[2]] | ||||
232 | echo $test[1..$n] | ||||
233 | echo $test[$n..1] | ||||
234 | echo The plural of $WORD is "$WORD"s | ||||
235 | echo The plural of $WORD is {$WORD}s | ||||
236 | echo $$foo[$i] | ||||
237 | echo $test[(count $test)..1] | ||||
238 | echo $test[1..(count $test[3])] | ||||
239 | | ||||
240 | #show error | ||||
241 | echo $PATH[error | ||||
242 | echo $PATH[1..error] | ||||
243 | | ||||
244 | echo $PATH[1 2 34 ] | ||||
245 | echo $PATH[1.. 2] | ||||
246 | echo $PATH[1 ..2] | ||||
247 | | ||||
248 | ### Brace Expansion | ||||
249 | echo input.{c,12h,TXT} | ||||
250 | echo input.{abc$test[(count $test)..1],(echo $txt)} | ||||
251 | echo input.{a{b,c},12h,TXT}} # show error | ||||
252 | | ||||
253 | | ||||
254 | ### Index range expansion | ||||
255 | echo (echo $a)[2..5] | ||||
256 | echo (echo $a)[2..5 1..3] | ||||
257 | echo (echo $a)[-1..1] | ||||
258 | | ||||
259 | ### Process expansion | ||||
260 | fg %ema # ??? | ||||
261 | | ||||
262 | | ||||
263 | ### Command substitution | ||||
264 | echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (/usr/bin/ls) (set_color normal) | ||||
265 | | ||||
266 | echo (#hallo)abc # ok | ||||
267 | echo (ls #hallo)abc # ok, die context-Tiefe ist anders | ||||
268 | echo (ls;#hallo)abc # als hier. | ||||
269 | echo (ls#hallo)abc # ok: # may be inner part of function names! | ||||
270 | echo (/usr/bin/ls) | ||||
271 | echo (ls >>mem/abc) | ||||
272 | echo (echo $test[2]) | ||||
273 | echo (/usr"/bi"n/ls /tmp) | ||||
274 | | ||||
275 | # multline command substitution | ||||
276 | set x (echo dirlist; # blabla | ||||
277 | ls) | ||||
278 | | ||||
279 | ## same, but commented out: | ||||
280 | | ||||
281 | # set x (echo dirlist; # blabla | ||||
282 | # ls) | ||||
283 | | ||||
284 | set pi (math "scale=10; 4*a(1)") | ||||
285 | | ||||
286 | ### Continuation lines | ||||
287 | ls \ | ||||
288 | /usr/bin | ||||
289 | | ||||
290 | test "STRING1"="STRING2" -a \ | ||||
291 | "STRING3" = (echo "STRING4") | ||||
292 | | ||||
293 | echo input.{abc\ | ||||
294 | ,12h,\ | ||||
295 | TXT} | ||||
296 | | ||||
297 | echo (\ | ||||
298 | ls) | ||||
299 | | ||||
300 | # no line continuation within single quotes | ||||
301 | echo 'abcdefg\ | ||||
302 | s$dfg sdf' | ||||
303 | # but within double quotes | ||||
304 | echo "123456\ | ||||
305 | 78910" | ||||
306 | echo $PATH[1..3\ | ||||
307 | ] | ||||
308 | ls /usr\ | ||||
309 | local/bin | ||||
310 | echo foo\ bar | ||||
311 | echo foo\ | ||||
312 | bar | ||||
313 | | ||||
314 | for i \ | ||||
315 | in \ | ||||
316 | a b c | ||||
317 | echo $i | ||||
318 | end | ||||
319 | | ||||
320 | # Bug? | ||||
321 | # Depending on weakDeliminators, either this works: | ||||
322 | cat\ alog -abc | ||||
323 | # or this: | ||||
324 | builtin\ | ||||
325 | --names jobs | ||||
326 | builtin \ | ||||
327 | --names jobs | ||||
328 | | ||||
329 | command \ | ||||
330 | ls | ||||
331 | | ||||
332 | eval \ | ||||
333 | ls . /tmp | ||||
334 | eval\ | ||||
335 | ls .../tmp | ||||
336 | | ||||
337 | set \ | ||||
338 | -e i[-1] | ||||
339 | set \ | ||||
340 | test1[-1..1] \ | ||||
341 | $test; \ | ||||
342 | echo $test1 | ||||
343 | | ||||
344 | read \ | ||||
345 | -gi test | ||||
346 | | ||||
347 | | ||||
348 | | ||||
349 | # see https://github.com/fish-shell/fish-shell/pull/1987 | ||||
350 | # this should work, but I found no way to implement it: | ||||
351 | echo before comment \ | ||||
352 | # comment | ||||
353 | # comment2 | ||||
354 | after comment # error: after should be just another argument | ||||
355 | from root | ||||
356 | | ||||
357 | echo "hello" | \ | ||||
358 | #remove 'l' | ||||
359 | #and more | ||||
360 | tr -d 'l' | ||||
361 | | ||||
362 | ### Trouble | ||||
363 | make; and make install; or make clean # ok | ||||
364 | printf '%s\t%s\n' flounder fish # ok | ||||
365 | diff (sort a.txt | psub) (sort b.txt | psub) | ||||
366 | source-highlight -f esc (cpp main.c | psub -s .c) | ||||
367 | | ||||
368 | while test -f foo.txt # comment | ||||
369 | echo hallo | ||||
370 | end | ||||
371 | | ||||
372 | for i in {1,(ls),3} # comment | ||||
373 | echo $i | ||||
374 | end | ||||
375 | | ||||
376 | # function | ||||
377 | function __hidden # comment | ||||
378 | cd / | ||||
379 | end | ||||
380 | | ||||
381 | function ll \ | ||||
382 | -d "multiline | ||||
383 | description" | ||||
384 | ls -l $argv | ||||
385 | end | ||||
386 | | ||||
387 | function ls --description="Description" -a a b c # comment | ||||
388 | command ls --color=auto $argv | ||||
389 | if test -f foo.txt | ||||
390 | echo foo.txt exists | ||||
391 | else if test -f bar.txt # comment | ||||
392 | echo bar.txt exists | ||||
393 | else | ||||
394 | echo foo.txt and bar.txt do not exist | ||||
395 | end # comment | ||||
396 | end | ||||
397 | | ||||
398 | function test;echo hallo;end # comment | ||||
399 | | ||||
400 | switch $animal # comment | ||||
401 | case cat # comment | ||||
402 | echo evil | ||||
403 | case wolf \ | ||||
404 | dog | ||||
405 | echo mammal | ||||
406 | case '*' | ||||
407 | echo I have no idea what a $animal is | ||||
408 | end | ||||
409 | | ||||
410 | if test (count $argv) = 1 | ||||
411 | echo $argv | ||||
412 | else | ||||
413 | echo "?" | ||||
414 | end | ||||
415 | | ||||
416 | if not test -f spoon #comment | ||||
417 | echo There is no spoon | ||||
418 | else | ||||
419 | exit 1 | ||||
420 | end | ||||
421 | | ||||
422 | for file in $cfgfiles | ||||
423 | if test -f $file | ||||
424 | string match -r '\[Dialer' < $file | string replace -r '\[Dialer (.+)\]' '$1' | ||||
425 | end | ||||
426 | end | sort -u | string match -v Defaults | ||||
427 | | ||||
428 | for i in *.c | ||||
429 | if grep smurf $i # comment | ||||
430 | echo Smurfs are present in $i | ||||
431 | break | ||||
432 | end | ||||
433 | end | ||||
434 | | ||||
435 | if begin contains -- $argv --force # ohne ; nach begin: geht | ||||
436 | or not status --is-interactive and not status --is-login | ||||
437 | end | ||||
438 | echo "" | ||||
439 | end | ||||
440 | | ||||
441 | begin # comment | ||||
442 | for i in *.tmp | ||||
443 | if grep smurf $i | ||||
444 | continue | ||||
445 | end | ||||
446 | rm $i | ||||
447 | end | ||||
448 | end | ||||
449 | | ||||
450 | if [ $status -eq 1 ] | ||||
451 | set sta pass | ||||
452 | else | ||||
453 | set sta fail | ||||
454 | end | ||||
455 | | ||||
456 | exec "$test" | ||||
457 | | ||||
458 | | ||||
459 | # Process Expansion | ||||
460 | # see fish issue 4230 | ||||
461 | kill -STOP %self | ||||
462 | |