File indexing completed on 2024-05-12 04:02:06

0001 #! /bin/sh
0002 # This is a test script for the Katepart Bash Syntax Highlighting by
0003 #       Wilbert Berendsen.  This is not runnable !!!
0004 
0005 
0006 # The highlighting recognizes basic types of input, and has a few special cases that
0007 # are all in FindCommands.  The main objective is to create really proper nesting of
0008 # (multiline) strings, variables, expressions, etc.
0009 
0010 
0011 
0012 # ============== Tests: ===============
0013 
0014 # basic types:
0015 echo 'single quoted string'
0016 echo "double quoted string"
0017 echo $'string with esc\apes\x0din it'
0018 echo $"string meant to be translated"
0019 echo "$"
0020 
0021 
0022 # comments:
0023 # this is a comment
0024 #this too
0025 echo this is#nt a comment
0026 dcop kate EditInterface#1 #this is
0027 grep -e "^default/linux/amd64/" |\ #this is not a comment but #this is
0028 mkdir this\ isnt\ #a\ comment
0029 mkdir this\ isnt\\\;#a\ comment
0030 mkdir this\\ #is a comment
0031 
0032 <<'#BLOCK-COMMENT'
0033 NOTE This is the "miltiline" comment.
0034 
0035 <beginfold id='1'>[===[.rst:</beginfold id='1'>
0036 
0037 Docs
0038 ----
0039 
0040 Documentation block in ``RST`` format **starts** *here*.
0041 
0042 <endfold id='1'>]===]</endfold id='1'>
0043 #BLOCK-COMMENT
0044 
0045 : << '#SC2188'
0046 <beginfold id='1'>[====[.rst:</beginfold id='1'>
0047 The *multiline* comment does not trigger the SC2188_ warning of `shellcheck`.
0048 
0049 .. _SC2188: https://www.shellcheck.net/wiki/SC2188
0050 <endfold id='1'>]====]</endfold id='1'>
0051 
0052 ... continue with _normal_ Bash comment.
0053 #SC2188
0054 
0055 # brace expansion
0056 mv my_file.{JPG,jpg}
0057 echo f.{01..100..3} f.{Z..a..-3}
0058 echo f.{01..100} f.{a..Z}
0059 # no brace expansion
0060 echo f.{..100} f.{1..Z} f.{a..Z..}
0061 
0062 
0063 # special characters are escaped:
0064 echo \(output\) \&\| \> \< \" \' \*
0065 
0066 
0067 # variable substitution:
0068 echo $filename.ext
0069 echo $filename_ext
0070 echo ${filename}_ext
0071 echo text${array[$subscript]}.text
0072 echo text${array["string"]}.text
0073 echo ${!prefix*}
0074 echo ${!redir} ${!3} ${!#} ${!##} ${!@###} ${!}
0075 echo short are $_, $$, $?, ${@}, etc.
0076 echo ${variable/a/d}
0077 echo ${1:-default}
0078 echo ${10} $10a # 9 is max
0079 
0080 
0081 # expression subst:
0082 echo <beginfold id='2'>$((</beginfold id='2'> cd << ed + 1 <endfold id='2'>))</endfold id='2'>
0083 
0084 
0085 # command subst:
0086 echo <beginfold id='3'>$(</beginfold id='3'>ls -l<endfold id='3'>)</endfold id='3'>
0087 echo `cat myfile`
0088 
0089 
0090 # file subst:
0091 echo <beginfold id='3'>$(</beginfold id='3'><$filename<endfold id='3'>)</endfold id='3'>
0092 echo <beginfold id='3'>$(</beginfold id='3'></path/to/myfile<endfold id='3'>)</endfold id='3'>
0093 
0094 # process subst:
0095 sort <(show_labels) | sed 's/a/bg' > my_file.txt 2>&1
0096 
0097 
0098 # All substitutions also work in strings:
0099 echo "subst ${in}side string"  'not $inside this ofcourse'
0100 echo "The result is <beginfold id='2'>$((</beginfold id='2'> $a + $b <endfold id='2'>))</endfold id='2'>. Thanks!"
0101 echo "Your homedir contains `ls $HOME |wc -l` files."
0102 
0103 
0104 # Escapes in strings:
0105 p="String \` with \$ escapes \" ";
0106 
0107 
0108 # keywords are black, builtins dark purple and common commands lighter purple
0109 set
0110 exit
0111 login
0112 
0113 
0114 # Other colorings:
0115 error() <beginfold id='4'>{</beginfold id='4'>
0116         cat /usr/bin/lesspipe.sh
0117         runscript >& redir.bak
0118         exec 3>&4
0119 <endfold id='4'>}</endfold id='4'>
0120 
0121 
0122 # do - done make code blocks
0123 while <beginfold id='2'>[</beginfold id='2'> $p -lt $q <endfold id='2'>]</endfold id='2'>
0124 <beginfold id='5'>do</beginfold id='5'>
0125         chown 0644 $file.$p
0126 <endfold id='5'>done</endfold id='5'>
0127 
0128 
0129 # braces as well
0130 run_prog | sort -u |
0131 <beginfold id='4'>{</beginfold id='4'>
0132         echo Header
0133         while read a b d
0134         <beginfold id='5'>do</beginfold id='5'>
0135                 echo $a/$b/$c
0136         <endfold id='5'>done</endfold id='5'>
0137         echo Footer
0138 <endfold id='4'>}</endfold id='4'>
0139 
0140 
0141 # Any constructions can be nested:
0142 echo "A long string with <beginfold id='3'>$(</beginfold id='3'>
0143         <beginfold id='6'>if</beginfold id='6'> <beginfold id='2'>[</beginfold id='2'> $count -gt 100 <endfold id='2'>]</endfold id='2'> ; then
0144                 echo "much"
0145         else
0146                 echo "not much"
0147         <endfold id='6'>fi</endfold id='6'> <endfold id='3'>)</endfold id='3'> substitutions." ;
0148 
0149 
0150 # Even the case construct is correctly folded:
0151 test -f blaat &&
0152 <beginfold id='3'>(</beginfold id='3'>  do_something
0153         <beginfold id='7'>case</beginfold id='7'> $p in
0154                 *bak<beginfold id='8'>)</beginfold id='8'>
0155                         do_bak $p
0156                         <endfold id='8'>;;</endfold id='8'>
0157                 *<beginfold id='8'>)</beginfold id='8'>
0158                         dont_bak $p
0159                         <endfold id='8'>;;</endfold id='8'>
0160         <endfold id='7'>esac</endfold id='7'>
0161 <endfold id='3'>)</endfold id='3'> # despite the extra parentheses in the case construction.
0162 
0163 
0164 # more control flow
0165 while :;
0166   break
0167   continue
0168   return
0169 <endfold id='5'>done</endfold id='5'>
0170 
0171 
0172 # variable assignments:
0173 DIR=/dev
0174 p=`ls`
0175 LC_ALL="nl" dcop 'kate*'
0176 _VAR=val
0177 ARR=(this is an array)
0178 ARR2=([this]=too [and]="this too")
0179 usage="$0 -- version $VERSION
0180 Multiple lines of output
0181 can be possible."
0182 ANSWER=yes      # here 'yes' isn't highlighed as command
0183 
0184 
0185 # Some commands expect variable names, these are colored correctly:
0186 export PATH=/my/bin:$PATH BLAAT
0187 export A B D
0188 local p=3  x  y='\'
0189 read x y z <<< $hallo
0190 unset B
0191 declare -a VAR1 VAR2 && exit
0192 declare less a && b
0193 declare a=(1 2)
0194 getopts :h:l::d arg
0195 read #comment
0196 let a=4+4 3+a b=c+3 d+3 d*4 # * is a glob
0197 
0198 # options are recoqnized:
0199 zip -f=file.zip
0200 ./configure  --destdir=/usr
0201 make  destdir=/usr/
0202 
0203 
0204 # [[ and [ correctly need spaces to be regarded as structure,
0205 # otherwise they are patterns (currently treated as normal text)
0206 <beginfold id='6'>if</beginfold id='6'> <beginfold id='2'>[</beginfold id='2'> "$p" == "" <endfold id='2'>]</endfold id='2'> ; then
0207         ls /usr/bin/[a-z]*
0208 elif <beginfold id='2'>[[</beginfold id='2'> $p == 0 <endfold id='2'>]]</endfold id='2'> ; then
0209         ls /usr/share/$p
0210 <endfold id='6'>fi</endfold id='6'>
0211 
0212 # Fixed:
0213 ls a[ab]*               # dont try to interprete as assignment with subscript (fixed)
0214 a[ab]
0215 a[ab]=sa
0216 
0217 
0218 # Here documents are difficult to catch:
0219 cat > myfile << __EOF__
0220 You're right, this is definitely no bash code
0221 But ls more $parameters should be expanded.
0222 __EOF__
0223 
0224 
0225 # quoted:
0226 cat << "EOF" | egrep "this" >&4   # the rest of the line is still considered bash source
0227 You're right, this is definitely no bash code
0228 But ls more $parameters should be expanded. :->
0229 EOF
0230 
0231 cat <<bla || exit
0232 bla bla
0233 bla
0234 
0235 
0236 # indented:
0237 <beginfold id='6'>if</beginfold id='6'> true
0238 then
0239         cat <<- EOF
0240                 Indented text with a $dollar or \$two
0241         EOF
0242 elif <beginfold id='2'>[</beginfold id='2'> -d $file <endfold id='2'>]</endfold id='2'>; then
0243         cat <<- "EOF"
0244                 Indented text without a $dollar
0245         EOF
0246 <endfold id='6'>fi</endfold id='6'>
0247 
0248 <beginfold id='6'>if</beginfold id='6'> ! <beginfold id='4'>{</beginfold id='4'> cmd1 && cmd2 ; <endfold id='4'>}</endfold id='4'>; then echo ok ; <endfold id='6'>fi</endfold id='6'>
0249 <beginfold id='6'>if</beginfold id='6'> ! cmd1 arg; then echo ok ; <endfold id='6'>fi</endfold id='6'>
0250 
0251 <beginfold id='7'>case</beginfold id='7'> 1 in
0252 2<beginfold id='8'>)</beginfold id='8'> echo xxx;
0253 <endfold id='8'>;;</endfold id='8'>
0254 ?<beginfold id='8'>)</beginfold id='8'> foo || yyy ; foo abc || echo abc <endfold id='8'>;;</endfold id='8'>
0255 1<beginfold id='8'>)</beginfold id='8'> echo yyy;
0256 <endfold id='8'></endfold id='8'><endfold id='7'>esac</endfold id='7'>
0257 
0258 ls #should be outside of case 1 folding block
0259 
0260 for i in `ls tests/auto/output/*.html`; <beginfold id='5'>do</beginfold id='5'>
0261     refFile=`echo $i | sed -e s,build,src, | sed -e s,output,reference, | sed -e s,.html,.ref.html,`
0262     cp -v $i $refFile
0263 <endfold id='5'>done</endfold id='5'>
0264 
0265 ## >Settings >Configure Kate >Fonts & Colors >Highlitghing Text Styles >Scripts/Bash >Option >Change colors to some distinct color
0266 ## 1- In following line the -ucode should not be colored as option
0267 
0268 pacman -Syu --needed intel-ucode grub
0269 pacman -syu --needed intel-ucode grub
0270 
0271 # Braces (bug ##387915)
0272 <beginfold id='2'>[[</beginfold id='2'> $line_name =~ \{([0-9]{1,})\}\{([0-9]{1,})\}(.*) <endfold id='2'>]]</endfold id='2'>
0273 <beginfold id='2'>[[</beginfold id='2'> $name =~ (.*)_(S[0-9]{2})(E[0-9]{2,3}[a-z]{0,1})_(.*) <endfold id='2'>]]</endfold id='2'>
0274 # Comments in Braces (bug 450878)
0275 <beginfold id='2'>[[</beginfold id='2'> # comment 1
0276    1 == 1 # comment 2
0277    # comment 3
0278 <endfold id='2'>]]</endfold id='2'>
0279 
0280 rm /data/{hello1,hello2}/input/{bye1,$bye2}/si{a,${b},c{k,p{e,a}}}/*.non
0281 rm /data/{aa,{e,i}t{b,c} # Not closed
0282 rm /data/{aa,{e,i}t{b,c}}
0283 rm /data/{aa,{i}}
0284 rm /data{aa{bb{cc{dd}}}}
0285 rm /data{aaa`aaa}aa`aaa}a
0286 
0287 ${array[0]: -7 : +  22  }  ${array[1]: num  }
0288 ${parameter##word} ${parameter%%word} ${parameter^^pattern} ${parameter,,pattern} ${parameter@operator}
0289 
0290 # TODO `
0291 
0292 # commands
0293 abc
0294 cp
0295 :
0296 .
0297 :#nokeyword
0298 path/cmd
0299 ec\
0300 ho
0301 2
0302 {ab}c
0303 {a,b}c
0304 'a'c
0305 $ab
0306 ${ab}c
0307 \ a
0308 !a
0309 {ab}[
0310 {a,b}[
0311 'a'[
0312 \ [
0313 !a[
0314 a{}d
0315 a{bc}d
0316 a{b,c}d
0317 a'b'c
0318 a$bc
0319 a${bc}d
0320 a\ b
0321 a!b
0322 a{}[
0323 a{bc}[
0324 a{b,c}[
0325 a'b'[
0326 a\ [
0327 a!b[
0328 
0329 # commands + params
0330 shortopt -ol -f/fd/fd -hfd/fds - -ol'a'b -f'a'/fd/fd -h'a'fd/fds
0331 longopt --long-a --long-b=value --file=* --file=file* --file=dir/file
0332 longopt --long-a'a'b --long'a'-b=value --fi'a'le=*
0333 noopt 3 3d -f -- -f --xx dir/file
0334 opt param#nocomment ab'a'cd [[ param ]] } { ~a .a #comments
0335 path path/file dir/ / // 3/f a@/ 'a'/b d/'a'b a\ d/f f/f\
0336 ile
0337 path ~ ~/ ~a/ . .. ./a ../a
0338 path /path/* /path/f* /path/f@ /path/f@(|) {a/b} a{b}/c a/b{c} a/{b} a/{b}c
0339 glob ? * ?f *f f* f? **/ ~/* ~* /path/f* 'a'* 'a'f/?
0340 extglob @ @(*) @(f*|f??(f)) f!(+(?(@(*(f)f)f)f)f)f @'a'@(|) a@(?)
0341 subs f! f!! f!s 'a'!s \( $v {a,b} {a} {a}/d {a\,} {a,} {a,\},b} ds/{a,b}sa/s
0342 2 - f -f
0343 !a -f
0344 'a' -f
0345 $a -f
0346 ! cmd
0347 
0348 # coproc command (#460301)
0349 coproc ls thisfiledoesntexist 2>&1
0350 coproc <beginfold id='4'>{</beginfold id='4'> ls thisfiledoesntexist; read; <endfold id='4'>}</endfold id='4'> 2>&1
0351 coproc mycoproc <beginfold id='4'>{</beginfold id='4'> awk '{print "foo" $0;fflush()}'; <endfold id='4'>}</endfold id='4'> >&3
0352 
0353 # redirections (prefix)
0354 <<<s cat
0355 <<<'s' cat
0356 <<<'s's cat
0357 <<<s's's cat
0358 <<<s${s}s cat
0359 <<< s${s}s cat
0360 >&2 cat
0361 <f cat
0362 < f cat
0363 2>3 cat
0364 2>&3 cat
0365 2>& 3 cat
0366 2>f cat
0367 &>f cat
0368 
0369 <<<# comment
0370 <# comment
0371 ># comment
0372 <<< # comment
0373 < # comment
0374 > # comment
0375 
0376 # redirections
0377 cat f>2
0378 cat d/f>2
0379 cat d/f >2
0380 cat d/f >& 2
0381 cat >2 d/f
0382 cat > 2
0383 cat <(echo) <(echo a) <(echo a/f) <(echo ) <(echo a ) <(echo a/f )
0384 cat 2>&1 &>f &>>f 2<&1- 2<>f 2<<heredoc
0385 bla bla
0386 heredoc
0387 <<-'h' cat
0388 bla
0389 h
0390 <<"'" cat
0391 bla
0392 '
0393 cat <<heredoc
0394 bla bla
0395 heredoc
0396 cat <<heredoc -a
0397 bla bla
0398 heredoc
0399 r=<beginfold id='3'>$(</beginfold id='3'>xxx $@ 2>&1<endfold id='3'>)</endfold id='3'>
0400 
0401 cat <<<# comment
0402 cat <# comment
0403 cat ># comment
0404 cat <<< # comment
0405 cat < # comment
0406 cat > # comment
0407 
0408 # branches
0409 cat a|cat
0410 cat a&cat
0411 cat a||cat
0412 cat a&&cat
0413 cat a;cat
0414 cat a | cat
0415 cat a & cat
0416 cat a || cat
0417 cat a && cat
0418 cat a ; cat
0419 cat a'a';cat
0420 
0421 # substitutions
0422 echo '' 'a' '\' "" "a" "\\" "$a" "a""a"'a''a' a'b'c a"b"c a$'\n'c
0423 echo a!bc a{a}b a{b,c}d a{b,{d,e}}d a\ b
0424 echo a$bc a$b/c a${b}c a<beginfold id='2'>$((</beginfold id='2'>b-3<endfold id='2'>))</endfold id='2'>c a<beginfold id='3'>$(</beginfold id='3'>b<endfold id='3'>)</endfold id='3'>c a<beginfold id='3'>$(</beginfold id='3'>a b c<endfold id='3'>)</endfold id='3'>c
0425 echo ${a[*]} ${a[@]} ${a[${b}]} ${a:-x$z} ${a-x} ${a/g} ${a//f/f} ${a//f*/f*}
0426 echo ${a^^l*} ${a,} ${!a} ${#a[1]} ${a:1:$b} <beginfold id='2'>$((</beginfold id='2'>++i,i--<endfold id='2'>))</endfold id='2'>
0427 echo "${var#lo+(r)em}" x "${var#+(r)em}" x
0428 echo "${var#refs/heads}" x "${var#refs}" x
0429 
0430 <beginfold id='2'>[</beginfold id='2'> a <endfold id='2'>]</endfold id='2'>
0431 <beginfold id='2'>[</beginfold id='2'> -f f'f'f <endfold id='2'>]</endfold id='2'>
0432 <beginfold id='2'>[</beginfold id='2'> -f f]'f'f] <endfold id='2'>]</endfold id='2'>
0433 <beginfold id='2'>[</beginfold id='2'> -t 13 <endfold id='2'>]</endfold id='2'>
0434 <beginfold id='2'>[</beginfold id='2'> -t 13] <endfold id='2'>]</endfold id='2'>
0435 <beginfold id='2'>[</beginfold id='2'> -t 13] <endfold id='2'>]</endfold id='2'>
0436 <beginfold id='2'>[</beginfold id='2'> -v abc <endfold id='2'>]</endfold id='2'>
0437 <beginfold id='2'>[</beginfold id='2'> -z abc <endfold id='2'>]</endfold id='2'>
0438 <beginfold id='2'>[</beginfold id='2'> abc -ef abc <endfold id='2'>]</endfold id='2'>
0439 <beginfold id='2'>[</beginfold id='2'> abc -ef abc <endfold id='2'>]</endfold id='2'>
0440 <beginfold id='2'>[</beginfold id='2'> abc-ef -ef abc-ef <endfold id='2'>]</endfold id='2'>
0441 <beginfold id='2'>[</beginfold id='2'> abc == abc <endfold id='2'>]</endfold id='2'>
0442 <beginfold id='2'>[</beginfold id='2'> abc < abc <endfold id='2'>]</endfold id='2'>
0443 <beginfold id='2'>[</beginfold id='2'> abc -eq abc <endfold id='2'>]</endfold id='2'>
0444 <beginfold id='2'>[[</beginfold id='2'> abc -eq abc <endfold id='2'>]]</endfold id='2'>
0445 <beginfold id='2'>[</beginfold id='2'> 1+2 -eq 1+2 <endfold id='2'>]</endfold id='2'>
0446 <beginfold id='2'>[[</beginfold id='2'> 1+2 -eq 1+2 <endfold id='2'>]]</endfold id='2'>
0447 <beginfold id='2'>[</beginfold id='2'> a = b <endfold id='2'>c</endfold id='2'> ]
0448 <beginfold id='2'>[[</beginfold id='2'> a = b <endfold id='2'>c</endfold id='2'> ]]
0449 <beginfold id='2'>[</beginfold id='2'> -z 1 -a 1 -eq 1 <endfold id='2'>]</endfold id='2'>
0450 <beginfold id='2'>[</beginfold id='2'> 2 -eq 1 -o 1 -eq 1 <endfold id='2'>]</endfold id='2'>
0451 <beginfold id='2'>[[</beginfold id='2'> x =~ a(b c|$)' '{1,}[a[.digit.]] <endfold id='2'>]]</endfold id='2'>
0452 <beginfold id='2'>[[</beginfold id='2'> x =~ [ <endfold id='2'>] </endfold id='2'>]]
0453 <beginfold id='2'>[[</beginfold id='2'> x =~ ([ ]) <endfold id='2'>]]</endfold id='2'>
0454 <beginfold id='2'>[[</beginfold id='2'> x =~ [ <endfold id='2'>]]</endfold id='2'>
0455 <beginfold id='2'>[[</beginfold id='2'> x =~ ([) <endfold id='2'>]]</endfold id='2'>
0456 <beginfold id='2'>[[</beginfold id='2'> (a =~ a) <endfold id='2'>]]</endfold id='2'>
0457 <beginfold id='2'>[[</beginfold id='2'> a =~ a || a -eq 2 <endfold id='2'>]]</endfold id='2'>
0458 <beginfold id='2'>[[</beginfold id='2'> (a =~ a) || a -eq 2 <endfold id='2'>]]</endfold id='2'>
0459 <beginfold id='2'>[[</beginfold id='2'> (0 -le $b) <endfold id='2'>]]</endfold id='2'>
0460 <beginfold id='2'>[[</beginfold id='2'> ( 0 -le $b ) <endfold id='2'>]]</endfold id='2'>
0461 <beginfold id='2'>[[</beginfold id='2'> ( 0 -le $b || $b -le 100 ) <endfold id='2'>]]</endfold id='2'>
0462 <beginfold id='2'>[[</beginfold id='2'> a<b <endfold id='2'>]]</endfold id='2'>
0463 <beginfold id='2'>[[</beginfold id='2'> a <b <endfold id='2'>]]</endfold id='2'>
0464 <beginfold id='2'>[[</beginfold id='2'> a< b <endfold id='2'>]]</endfold id='2'>
0465 <beginfold id='2'>[[</beginfold id='2'> a < b <endfold id='2'>]]</endfold id='2'>
0466 <beginfold id='2'>[[</beginfold id='2'>(! -d .)<endfold id='2'>]]</endfold id='2'>
0467 <beginfold id='2'>[[</beginfold id='2'> ! -d . <endfold id='2'>]]</endfold id='2'>
0468 <beginfold id='2'>[[</beginfold id='2'> !(-d .) <endfold id='2'>]]</endfold id='2'>
0469 <beginfold id='2'>[[</beginfold id='2'> -f a || -f b <endfold id='2'>]]</endfold id='2'>
0470 <beginfold id='2'>[[</beginfold id='2'> -f a||-f b <endfold id='2'>]]</endfold id='2'>
0471 <beginfold id='2'>[[</beginfold id='2'> ! (a -eq b) <endfold id='2'>]]</endfold id='2'>
0472 <beginfold id='2'>[</beginfold id='2'> -d `echo .`] <endfold id='2'>]</endfold id='2'>
0473 <beginfold id='2'>[[</beginfold id='2'> -d `echo .`]] <endfold id='2'>]]</endfold id='2'>
0474 <beginfold id='2'>[[</beginfold id='2'> a != b && ${a}a = b${b} <endfold id='2'>]]</endfold id='2'>
0475 <beginfold id='2'>[[</beginfold id='2'>
0476   1 -eq 2
0477 <endfold id='2'>]]</endfold id='2'>
0478 <beginfold id='2'>[[</beginfold id='2'> -&&- <endfold id='2'>]]</endfold id='2'>
0479 <beginfold id='2'>[[</beginfold id='2'> <endfold id='2'>]]</endfold id='2'>
0480 <beginfold id='2'>[[</beginfold id='2'> -f <endfold id='2'>]]</endfold id='2'>
0481 <beginfold id='2'>[[</beginfold id='2'> -f [0-9a] <endfold id='2'>]]</endfold id='2'>
0482 <beginfold id='2'>[[</beginfold id='2'> ?*[0-9] = [^0-9] <endfold id='2'>]]</endfold id='2'>
0483 <beginfold id='2'>[[</beginfold id='2'> -f = ?*[0-9] <endfold id='2'>]]</endfold id='2'>
0484 <beginfold id='2'>[[</beginfold id='2'> ?*[0-9] = ?*[0-9] <endfold id='2'>]]</endfold id='2'>
0485 <beginfold id='2'>[[</beginfold id='2'> a/sa[s = dsad?*[0-9]dsa$ds <endfold id='2'>]]</endfold id='2'>
0486 <beginfold id='2'>[[</beginfold id='2'> a/sa[s = dsad?*[0-9]ds/a$ds <endfold id='2'>]]</endfold id='2'>
0487 <beginfold id='2'>[[</beginfold id='2'> a =~ [12]a([!d]a?s[x[:alnum:]]|d?)p <endfold id='2'>]]</endfold id='2'>
0488 
0489 <beginfold id='2'>[[</beginfold id='2'> #comm1
0490  #comm2
0491  p[1] == p[2]
0492  #comm3
0493  #comm4
0494 <endfold id='2'>]]</endfold id='2'>
0495 
0496 <beginfold id='2'>[[</beginfold id='2'> #comm1
0497  #comm2
0498  -f p[2]
0499  #comm3
0500  #comm4
0501 <endfold id='2'>]]</endfold id='2'>
0502 
0503 <beginfold id='2'>((</beginfold id='2'>3+1+a+$c*(x) & 0x43422fd+03-085/23#D9a@_^8<endfold id='2'>))</endfold id='2'>
0504 <beginfold id='2'>((</beginfold id='2'>1/(2-(a-4))<endfold id='2'>))</endfold id='2'>
0505 
0506 # they are not arithmetic evaluations...
0507 <beginfold id='3'>(</beginfold id='3'><beginfold id='3'>(</beginfold id='3'>cmd && cmd<endfold id='3'>)</endfold id='3'> || cmd<endfold id='3'>)</endfold id='3'>
0508 <beginfold id='3'>$(</beginfold id='3'><beginfold id='3'>(</beginfold id='3'>cmd && cmd<endfold id='3'>)</endfold id='3'> || cmd<endfold id='3'>)</endfold id='3'>
0509 <beginfold id='2'>((</beginfold id='2'>cmd &&
0510 cmd<endfold id='2'></endfold id='2'><beginfold id='3'>)</beginfold id='3'> || cmd<endfold id='3'>)</endfold id='3'>
0511 <beginfold id='2'>$((</beginfold id='2'>cmd &&
0512 cmd<endfold id='2'></endfold id='2'><beginfold id='3'>)</beginfold id='3'> || cmd<endfold id='3'>)</endfold id='3'>
0513 
0514 <beginfold id='4'>{</beginfold id='4'> echo
0515     echo
0516 <endfold id='4'>}</endfold id='4'>
0517 <beginfold id='4'>{</beginfold id='4'> echo ; <endfold id='4'>}</endfold id='4'>
0518 <beginfold id='3'>(</beginfold id='3'>echo ; echo<endfold id='3'>)</endfold id='3'>
0519 <beginfold id='3'>(</beginfold id='3'>echo
0520     echo<endfold id='3'>)</endfold id='3'>
0521 <beginfold id='3'>(</beginfold id='3'>echo a<endfold id='3'>)</endfold id='3'>
0522 <beginfold id='3'>(</beginfold id='3'><beginfold id='4'>{</beginfold id='4'> echo plop;<endfold id='4'>}</endfold id='4'><endfold id='3'>)</endfold id='3'>
0523 <beginfold id='2'>[</beginfold id='2'> a -eq 2 <endfold id='2'>]</endfold id='2'> || <beginfold id='2'>[</beginfold id='2'> a -eq 2] <endfold id='2'>]</endfold id='2'> && <beginfold id='2'>[[</beginfold id='2'> a -eq 2 <endfold id='2'>]]</endfold id='2'> || <beginfold id='2'>[[</beginfold id='2'> a != b <endfold id='2'>]]</endfold id='2'>;
0524 <beginfold id='2'>[</beginfold id='2'> a -eq 2 <endfold id='2'>]</endfold id='2'>||<beginfold id='2'>[</beginfold id='2'> a -eq 2] <endfold id='2'>]</endfold id='2'>&&<beginfold id='2'>[[</beginfold id='2'> a -eq 2 <endfold id='2'>]]</endfold id='2'>||<beginfold id='2'>[[</beginfold id='2'> a != b <endfold id='2'>]]</endfold id='2'>;
0525 test a -eq b
0526 
0527 # functions
0528 a() <beginfold id='4'>{</beginfold id='4'> echo x; <endfold id='4'>}</endfold id='4'>
0529 a  () <beginfold id='4'>{</beginfold id='4'> echo x; <endfold id='4'>}</endfold id='4'>
0530 function f <beginfold id='4'>{</beginfold id='4'> echo x; <endfold id='4'>}</endfold id='4'>
0531 kde.org() <beginfold id='4'>{</beginfold id='4'> echo x; <endfold id='4'>}</endfold id='4'>
0532 --func() <beginfold id='4'>{</beginfold id='4'> echo x; <endfold id='4'>}</endfold id='4'>
0533 
0534 # variables
0535 a=(a b c)
0536 a='a'
0537 a+=b
0538 a[1]='a'
0539 a[$i]='x'
0540 a[<beginfold id='2'>$((</beginfold id='2'>
0541     2+4
0542 <endfold id='2'>))</endfold id='2'>]='x'
0543 a=([a]=2 `echo` -s > 'ds')
0544 a=(#comment
0545 value#nocomment #comment)
0546 )
0547 a=a cat
0548 a=`ls` cat
0549 
0550 # errors
0551 a a(s<endfold id='3'>)</endfold id='3'> a
0552 
0553 # control structure
0554 for name in a b c {d,e} ; <beginfold id='5'>do</beginfold id='5'> echo ; <endfold id='5'>done</endfold id='5'>
0555 for name; <beginfold id='5'>do</beginfold id='5'> echo ; <endfold id='5'>done</endfold id='5'>
0556 for name <beginfold id='5'>do</beginfold id='5'> echo ; <endfold id='5'>done</endfold id='5'>
0557 for ((i=0;i<5;++i)) ; <beginfold id='5'>do</beginfold id='5'> echo $i ; <endfold id='5'>done</endfold id='5'>
0558 select name in a ; <beginfold id='5'>do</beginfold id='5'> echo ; <endfold id='5'>done</endfold id='5'>
0559 select name; <beginfold id='5'>do</beginfold id='5'> echo ; <endfold id='5'>done</endfold id='5'>
0560 <beginfold id='6'>if</beginfold id='6'> : ; then echo ; elif <beginfold id='2'>[[</beginfold id='2'> : <endfold id='2'>]]</endfold id='2'> ; then echo ; else echo ; <endfold id='6'>fi</endfold id='6'>
0561 while : || : ; <beginfold id='5'>do</beginfold id='5'> echo ; <endfold id='5'>done</endfold id='5'>
0562 until : ; : ; <beginfold id='5'>do</beginfold id='5'> echo ; <endfold id='5'>done</endfold id='5'>
0563 <beginfold id='7'>case</beginfold id='7'> a in a<beginfold id='8'>)</beginfold id='8'> <endfold id='8'></endfold id='8'><endfold id='7'>esac</endfold id='7'>
0564 <beginfold id='7'>case</beginfold id='7'> a in a<beginfold id='8'>)</beginfold id='8'> echo ; <endfold id='8'></endfold id='8'><endfold id='7'>esac</endfold id='7'>
0565 <beginfold id='7'>case</beginfold id='7'> pwd in (patt1<beginfold id='8'>)</beginfold id='8'> echo ; echo <endfold id='8'>;;</endfold id='8'> (patt*<beginfold id='8'>)</beginfold id='8'> echo <endfold id='8'>;;&</endfold id='8'> patt?|patt<beginfold id='8'>)</beginfold id='8'> echo <endfold id='8'>;&</endfold id='8'>
0566 patt<beginfold id='8'>)</beginfold id='8'> echo <endfold id='8'>;;</endfold id='8'> <endfold id='7'>esac</endfold id='7'>
0567 
0568 for name in a
0569  b c ;
0570 <beginfold id='5'>do</beginfold id='5'>
0571 echo
0572 <endfold id='5'>done</endfold id='5'>
0573 
0574 <beginfold id='7'>case</beginfold id='7'> a in
0575   a\( | b*c? <beginfold id='8'>)</beginfold id='8'> echo
0576   <beginfold id='3'>(</beginfold id='3'>b$c<endfold id='3'>)</endfold id='3'> # no pattern
0577   <endfold id='8'>;;</endfold id='8'>
0578   (b$c<beginfold id='8'>)</beginfold id='8'> <endfold id='8'>;;</endfold id='8'>
0579   # no pattern
0580   (b$c<beginfold id='8'>)</beginfold id='8'>
0581 <endfold id='8'></endfold id='8'><endfold id='7'>esac</endfold id='7'>
0582 
0583 <beginfold id='7'>case</beginfold id='7'> "$1" in
0584  "a"<beginfold id='8'>)</beginfold id='8'> run_a|&a<endfold id='8'>;;</endfold id='8'>
0585  "b"<beginfold id='8'>)</beginfold id='8'> run_b<endfold id='8'>;;</endfold id='8'>
0586  "c"<beginfold id='8'>)</beginfold id='8'> run_c<endfold id='8'>;;</endfold id='8'>
0587  *<beginfold id='8'>)</beginfold id='8'> echo "Plase choose between 'a', 'b' or 'c'" && exit 1<endfold id='8'>;;</endfold id='8'>
0588 <endfold id='7'>esac</endfold id='7'>