1#!/bin/bash 2 3[ -f testing.sh ] && . testing.sh 4 5#testing "name" "command" "result" "infile" "stdin" 6 7if [ -z "$(which bash)" ] 8then 9 echo "$SHOWSKIP: no bash alias" 10 return 2>/dev/null 11 exit 12fi 13 14shellit() 15{ 16 EVAL="bash -c" testing "$2" "$1 printf %s $2" "$3" "$4" "$5" 17} 18 19# $'' expands special chars but doesn't do so inside double quotes. 20 21shellit "" "\$'a\\tb'" "a\tb" "" "" 22shellit "" "\"\$'a\\tb'\"" '$'"'"'a\\tb'"'" "" "" 23 24# $(( )) tests 25 26shellit 'x=1;' '$((-x))' '-1' '' '' 27shellit 'x=0;' '$((x++)); echo $x' '01\n' '' '' 28shellit 'x=0;' '$((++x))' '1' '' '' 29shellit 'x=0;' '$((~x))' '-1' '' '' 30shellit 'x=1;' '$((!x))' '0' '' '' 31shellit 'x=0;' '$((!x))' '1' '' '' 32shellit 'x=2;' '$((2*x))' '4' '' '' 33shellit 'x=9;' '$((x/4))' '2' '' '' 34shellit 'x=9;' '$((x%4))' '1' '' '' 35shellit 'x=4;' '$((x+2))' '6' '' '' 36shellit 'x=4;' '$((x-2))' '2' '' '' 37shellit 'x=4;' '$((1<<x))' '16' '' '' 38shellit 'x=4;' '$((x>>1))' '2' '' '' 39shellit '' '$((3**4))' '81' '' '' 40shellit '' '$((3<=4))' '1' '' '' 41shellit '' '$((3>=4))' '0' '' '' 42shellit '' '$((3<4))' '1' '' '' 43shellit '' '$((3>4))' '0' '' '' 44shellit '' '$((3==4))' '0' '' '' 45shellit '' '$((3!=4))' '1' '' '' 46shellit '' '$((6&4))' '4' '' '' 47shellit '' '$((4|2))' '6' '' '' 48shellit '' '$((6&&2))' '1' '' '' 49shellit '' '$((6||4))' '1' '' '' 50shellit '' '$((1?2:3))' '2' '' '' 51shellit 'x=2;' '$((x=3)); echo $x' '33\n' '' '' 52shellit 'x=2;' '$((x*=3)); echo $x' '66\n' '' '' 53shellit 'x=5;' '$((x/=2)); echo $x' '22\n' '' '' 54shellit 'x=9;' '$((x%=5)); echo $x' '44\n' '' '' 55shellit 'x=9;' '$((x-=3)); echo $x' '66\n' '' '' 56shellit 'x=3;' '$((x+=2)); echo $x' '55\n' '' '' 57shellit 'x=7;' '$((x&=13)); echo $x' '55\n' '' '' 58shellit 'x=5;' '$((x|=12)); echo $x' '1313\n' '' '' 59shellit 'x=5;' '$((x^=12)); echo $x' '99\n' '' '' 60shellit 'x=2;' '$((x<<=2)); echo $x' '88\n' '' '' 61shellit 'x=12;' '$((x>>=2)); echo $x' '33\n' '' '' 62shellit 'x=2;' '$((x++,5)); echo $x' '53\n' '' '' 63 64# echo $(ls -l #comment) 65# cat -</dev/null 66# cat -|xargs echo 67# cat -(ls) 68# echo -! 69# echo -{ 70# echo -( 71# (echo -) 72# echo $ 73# "echo \$(echo \"hello\nworld\")" 74# "echo \"one ;\ntwo\"" 75# echo $(ls -l &) 76# echo one < /dev/null two 77