Warning, /frameworks/syntax-highlighting/autotests/input/highlight.fish is written in an unsupported language. File is not indexed.

0001 ### Comments
0002 # TODO
0003 # BEGIN
0004 #    fg sfg sfh sft
0005 # END
0006 #
0007 # text in (parenthesis) is ok, (even
0008 # over several lines)
0009 # escaped \) and \( are ok
0010 # an unbalanced single ) is not ok
0011 # This is due to fish comment handling in command substitutions
0012 # which cannot reasonably handled by kate syntax highlighting
0013 
0014 
0015 ### Commands and paths
0016 ls -l |sort
0017 ls -1
0018 /usr/bin/ls -l /usr/local/test/ -xyz       # option as indicator of CommandArgs context
0019 ./bin/ls -l /usr/abc**/tes?/lkhlk       -xyz   # tabulator as separator
0020 ../bin/ls -l /usr/abc**/tes?/lkhlk
0021 ~/bin/ls -l ../usr/lo\ cal/test
0022 ~user/bin/ls -l /usr/{local,remote}}/test|cat  # show error
0023 /usr/bin/../lib/ls -l /usr/local/test.???|cat
0024 /usr/bin\ sdfg/ls -l /usr/local/test.*
0025 usr/bin/other -l ~user/local/test
0026 \ usr/bin/other -l ~user/local/test
0027 /usr/bin/lsother
0028 ../test/root/bin/fish -c "echo $t8"
0029 test/root/bin/fish -c "echo $t8"
0030 u?r/bin/ls
0031 usr/b?n/ls
0032 u*ls        # doesn't work, but ok
0033 "ls" /tmp/testtest                         # Quotes in commands are expanded
0034 /us"r/bin"/xy/ls
0035 abcd$a      # show error
0036 other) abc  # show error
0037 <other abc  # show error
0038 other> abc  # ok
0039 oth>er abc  # ok
0040 ot(her) abc # show error
0041 
0042 -cmd
0043 déjà-vu
0044 
0045 ls /ho"me/te"st'user'/abc$dir[3]/ab(echo cdefg)cd/xyz
0046 cat\ alog -abc
0047 ls path_not_detected
0048 ls * no_path
0049 ls *path_detected
0050 ls/
0051 ls;echo xy
0052 flex++
0053 echo [abc] abc
0054 
0055 #specials
0056 command -s ls
0057 builtin --names jobs
0058 exec bash
0059 exec $test
0060 set -e i[-1]
0061 set test1[-1..1] $test; echo $test1
0062 set test1[1..$n] $test; echo $test1
0063 set test1[$n..1] $test; echo $test1
0064 set test1[2..4 -2..-4] $test1[4..2 -4..-2]; echo $test1
0065 set test1[2..4 -2..-4][1] $test1[4..2 -4..-2][1]
0066 #                     ~~~ invalid
0067 set test1\
0068 [2..4 -2..-4]\
0069 [1] a
0070 #~~ invalid
0071 set test1 \
0072     #bla bla
0073     a b c
0074 set page_url http://fishshell.com/docs/$version_string/$fish_help_page    # ???
0075 string split . example.com
0076 set b (string repeat -n 512 x)
0077 
0078 read -gi test    # ok
0079 read -gi $test
0080 read -gi "test"
0081 read -gi (echo test)
0082 
0083 set x (string split --max 1 --right / (status current-filename) #Comment test)
0084 set test (exec $cmd)
0085 
0086 # direct path
0087 test -d $tmpldir/resources
0088 
0089 ### Options
0090 cat -l /usr/local/test>logfile
0091 ls --longopt=/test
0092 ls -l"kasdflakjs" -r/usr/test -x../test/../bla -z~xyz/hello
0093 
0094 ### Arguments
0095 echo abc"def"ghi
0096 echo abc/def
0097 echo abc[de]
0098 echo abc(echo def)ghi
0099 echo abc{de,f}ghi
0100 
0101 # Path Detection
0102 cd abc*efghi  # fish assumes * is glob -> path
0103 cd abc?efghi
0104 cd ..
0105 cd .. #
0106 cd .
0107 cd . #
0108 cd ~
0109 cd ~abc/abc/*.txt
0110 cd ./abc
0111 cd ../abc
0112 cd \ abc/tmp\ .txt
0113 
0114 test .. abc
0115 
0116 ### Escapes
0117 touch a\?bc\[\]ax\~dsf\#gsd\af\(\)dg\?sd\ fg\bhh\%j\$k\\l\?sed\*jk\>hj\<hou\&h\;hgkj\^kj\"kjh\'jhg
0118 touch sdf\xa5lh\Xb7kll\157j\158hk\ua47bz\U123b5678fs\cxzdfga
0119 
0120 touch "a\?bc\[\]a"      # no escaping in Quotes
0121 touch fgh\y1            # \y is no escape sequence in fish, show it as normal text like fish itself
0122 
0123 ### Builtins
0124 . hallo
0125 source hallo 
0126 eval ls . /tmp
0127 eval ls .../tmp
0128 eval $var
0129 eval abc
0130 eval {l,a}s  # lists ./as. colours not ok, but we cut here
0131 eval "echo bla"
0132 
0133 history merge
0134 
0135 true ;ls
0136 echo (true)
0137 echo (true #comment)
0138 echo (true>>xyz/abc)
0139 true -error     # show error
0140 pwd > abc
0141 
0142 command -s ls;cat test
0143 builtin -n;builtin echo
0144 
0145 complete -c myprog -s o -l output -a "yes no"
0146 builtin jobs
0147 
0148 math -s0 10.0 / 6.0
0149 
0150 #special keywords as directory names:
0151 /usr/function/testtest /usr/function/testtest
0152 /usr/for/testtest /usr/for/testtest
0153 /usr/begin/testtest /usr/begin/testtest
0154 /usr/switch/testtest /usr/switch/testtest
0155 /usr/if/testtest /usr/if/testtest
0156 /usr/while/testtest /usr/while/testtest
0157 /usr/command/testtest /usr/command/testtest
0158 /usr/builtin/testtest /usr/builtin/testtest
0159 /usr/eval/testtest /usr/eval/testtest
0160 /usr/exec/testtest /usr/exec/testtest
0161 /usr/set/testtest /usr/set/testtest
0162 /usr/test/testtest /usr/test/testtest
0163 
0164 ### test
0165 test NUM1 -eq NUM2
0166 test -f /tmp/abc -a -e /tmp/def;cat /tmp/abc;
0167 
0168 if test \( -f /foo -o -f /bar \) -a \( -f /baz -o -f /bat \)
0169     echo Success.
0170 end
0171 
0172 [ 25 -eq $NUM2 ]
0173 [ "abc" = "$STRING2" ]
0174 
0175 if [ ! \(STRING1 != STRING2\) ];ls;end
0176 if [ -f abc ]# show error
0177 end
0178 if [ -f abc ] # ok
0179 end
0180 
0181 if [ ! \(STRING1 != STRING2\) ] ls;end # show error
0182 if [ "abc" != "def" ] # hallo
0183    echo x;end
0184 
0185 ### Redirections
0186 ls < SOURCE_FILE         # stdin
0187 ls > DESTINATION         # stdout
0188 ls ^ DESTINATION         # stderr
0189 ls >> DESTINATION_FILE   # append
0190 ls ^^ DESTINATION_FILE   # append
0191 ls >? DESTINATION        # noclobber
0192 ls ^? DESTINATION
0193 
0194 ls ^? ~
0195 ls ^? ~testuser/abc
0196 ls ^?/DESTINATION
0197 ls ^?#DESTINATION       # show error
0198 
0199 ls > $abc[5]
0200 ls >"abc"/defg$v/xyz
0201 
0202 ls >&                   # show error
0203 ls > &1                 # show error
0204 ls abc>&25 xyz /tmp/xyz $abc
0205 ls /tmp/tst>&25?        # show error
0206 ls /tmp/tst>&25 ?       # ok
0207 ls 3>&- xyz
0208 ls 1<DESTINATION
0209 echo Hello > all_output.txt ^&1 xyz
0210 ls 2>&-;echo end
0211 ls xyz 2>|cat
0212 
0213 ls>x
0214 abs>x
0215 /bin/ls>x
0216 /bin/abs>x
0217 
0218 ### Quoting
0219 echo 'abcdefg'
0220 echo 'abc\'de\\fg'
0221 echo 'abc\defg'
0222 
0223 echo "1\"23\$45\\6"
0224 echo '1\"23\$45\\6'
0225 echo '
0226 hallo
0227 '
0228 echo "$i: '$$name[1][$i]'"
0229 
0230 
0231 ### Piping, Pipelines and background jobs
0232 ls -l /tmp/hello 1<DEST| sort
0233 comand_1;command_2
0234 comand_1 ;command_2
0235 ls;ls
0236 run_long_job & ls  # yes & is a command sequencing operator like | and ;
0237 cat foo.txt | head
0238 make fish 2>| less #show error
0239 
0240 ### Variable Expansion
0241 echo $PATH
0242 echo $PATH[1..3]
0243 echo $PATH[-1..3 5 9..15]
0244 echo $PATH[$n[2]]
0245 echo $test[1..$n]
0246 echo $test[$n..1]
0247 echo The plural of $WORD is "$WORD"s
0248 echo The plural of $WORD is {$WORD}s
0249 echo $$foo[$i]
0250 echo $test[(count $test)..1]
0251 echo $test[1..(count $test[3])]
0252 echo $$foo[1..-1][5]
0253 echo $$foo[1..-1]\
0254 [5][2]\
0255 [5]
0256 
0257  #show error
0258 echo $PATH[error
0259 echo $PATH[1..error]
0260 
0261 echo $PATH[1 2 34 ]
0262 echo $PATH[1.. 2]
0263 echo $PATH[1 ..2]
0264 
0265 ### Brace Expansion
0266 echo input.{c,12h,TXT}
0267 echo input.{abc$test[(count $test)..1],(echo $txt)}
0268 echo input.{a{b,c},12h,TXT}}  # show error
0269 
0270 
0271 ### Index range expansion
0272 echo (echo $a)[2..5]
0273 echo (echo $a)[2..5 1..3]
0274 echo (echo $a)[-1..1]
0275 
0276 ### Process expansion
0277 fg %ema               # ???
0278 
0279 
0280 ### Command substitution
0281 echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (/usr/bin/ls) (set_color normal) 
0282 
0283 echo (#hallo)abc      # ok
0284 echo (ls #hallo)abc   # ok, die context-Tiefe ist anders
0285 echo (ls;#hallo)abc   #     als hier.
0286 echo (ls#hallo)abc    # ok: # may be inner part of function names!
0287 echo (/usr/bin/ls)
0288 echo (ls >>mem/abc)
0289 echo (echo $test[2])
0290 echo (/usr"/bi"n/ls /tmp)
0291 echo (seq 10)[1][2]
0292 #               ~~~ not an index
0293 echo (seq 10)\
0294 [1][2]
0295 #  ~~~ not an index
0296 echo (seq 10)\
0297 [1]\
0298 [2]
0299 #~~ not an index
0300 
0301 # multline command substitution
0302 set x (echo dirlist; # blabla
0303        ls)
0304 
0305 ## same, but commented out:
0306 
0307 # set x (echo dirlist; # blabla
0308 #        ls)
0309 
0310 set pi (math "scale=10; 4*a(1)")
0311 
0312 ### Continuation lines
0313 ls \
0314   /usr/bin
0315 
0316 test "STRING1"="STRING2" -a \
0317      "STRING3" = (echo "STRING4")
0318 
0319 echo input.{abc\
0320 ,12h,\
0321 TXT}
0322 
0323 echo (\
0324       ls)
0325 
0326 # no line continuation within single quotes
0327 echo 'abcdefg\
0328        s$dfg sdf'
0329 # but within double quotes
0330 echo "123456\
0331       78910"
0332 echo $PATH[1..3\
0333           ]
0334 ls /usr\
0335 local/bin
0336 echo foo\ bar
0337 echo foo\
0338 bar
0339 
0340 for i \
0341     in \
0342     a b c
0343     echo $i
0344 end
0345 
0346 # Bug?
0347 # Depending on weakDeliminators, either this works:
0348 cat\ alog -abc
0349 # or this:
0350 builtin\
0351  --names jobs
0352 builtin \
0353 --names jobs
0354 
0355 command \
0356    ls
0357 
0358 eval \
0359    ls . /tmp
0360 eval\
0361    ls .../tmp
0362 
0363 set \
0364   -e i[-1]
0365 set \
0366    test1[-1..1] \
0367    $test; \
0368    echo $test1
0369 
0370 read \
0371   -gi test
0372 
0373 
0374 
0375 # see https://github.com/fish-shell/fish-shell/pull/1987
0376 echo before comment \
0377   # comment
0378   # comment2
0379   after comment # just another argument
0380 echo before comment\
0381   # comment        ^ no space
0382   # comment2
0383   after comment # a command
0384 from root
0385 
0386 echo "hello" | \
0387 #remove 'l'
0388 #and more
0389 tr -d 'l'
0390 
0391 ### Trouble
0392 make; and make install; or make clean              # ok
0393 printf '%s\t%s\n' flounder fish                    # ok
0394 diff (sort a.txt | psub) (sort b.txt | psub)
0395 source-highlight -f esc (cpp main.c | psub -s .c)
0396 
0397 while test -f foo.txt  # comment
0398   echo hallo
0399 end
0400 
0401 for i in {1,(ls),3}    # comment
0402   echo $i
0403 end
0404 
0405 # function
0406 function __hidden      # comment
0407   cd /
0408 end
0409 
0410 function ll \
0411   -d "multiline
0412   description"
0413     ls -l $argv
0414 end
0415 
0416 function ls --description="Description" -a a b c # comment
0417     command ls --color=auto $argv
0418     if test -f foo.txt
0419         echo foo.txt exists
0420     else if test -f bar.txt          # comment
0421         echo bar.txt exists
0422     else
0423         echo foo.txt and bar.txt do not exist
0424     end                              # comment
0425 end
0426 
0427 function test;echo hallo;end         # comment
0428 
0429 switch $animal   # comment
0430     case cat     # comment
0431         echo evil
0432     case wolf \
0433         dog
0434         echo mammal
0435     case '*'
0436         echo I have no idea what a $animal is
0437 end
0438 
0439 if test (count $argv) = 1
0440   echo $argv
0441 else
0442   echo "?"
0443 end
0444 
0445 if not test -f spoon   #comment
0446   echo There is no spoon
0447 else
0448   exit 1
0449 end
0450 
0451 for file in $cfgfiles
0452     if test -f $file
0453         string match -r '\[Dialer' < $file | string replace -r '\[Dialer (.+)\]' '$1'
0454     end
0455 end | sort -u | string match -v Defaults
0456 
0457 for i in *.c
0458     if grep smurf $i     # comment
0459         echo Smurfs are present in $i
0460         break
0461     end
0462 end
0463 
0464 if begin contains -- $argv --force   # ohne ; nach begin: geht
0465         or not status --is-interactive and not status --is-login
0466     end
0467     echo ""
0468 end
0469 
0470 begin                    # comment
0471   for i in *.tmp
0472       if grep smurf $i
0473           continue
0474       end
0475       rm $i
0476   end
0477 end
0478 
0479 if [ $status -eq 1 ]
0480         set sta pass
0481 else
0482         set sta fail
0483 end
0484 
0485 exec "$test"
0486 
0487 
0488 # Process Expansion
0489 # see fish issue 4230
0490 kill -STOP %self
0491 
0492 endcmd # is a command
0493 
0494 for inc in a # inc is a variable
0495 end
0496 
0497 switch d;case "*" ; case d;echo; end
0498 
0499 if ; else if ; else if ; if ; else ; end;else ; end