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