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

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