1 2failures='' 3ok='' 4 5testcase() { 6 code="$1" 7 expected="$2" 8 oIFS="$IFS" 9 eval "$code" 10 IFS='|' 11 result="$#|$*" 12 IFS="$oIFS" 13 if [ "x$result" = "x$expected" ]; then 14 ok=x$ok 15 else 16 failures=x$failures 17 echo "For $code, expected $expected actual $result" 18 fi 19} 20 21testcase 'set -- a b; set -- p$@q' '2|pa|bq' 22testcase 'set -- a b; set -- $@q' '2|a|bq' 23testcase 'set -- a b; set -- p$@' '2|pa|b' 24testcase 'set -- a b; set -- p$@q' '2|pa|bq' 25testcase 'set -- a b; set -- $@q' '2|a|bq' 26testcase 'set -- a b; set -- p$@' '2|pa|b' 27testcase 'set -- a b; set -- p$*q' '2|pa|bq' 28testcase 'set -- a b; set -- $*q' '2|a|bq' 29testcase 'set -- a b; set -- p$*' '2|pa|b' 30testcase 'set -- a b; set -- p$*q' '2|pa|bq' 31testcase 'set -- a b; set -- $*q' '2|a|bq' 32testcase 'set -- a b; set -- p$*' '2|pa|b' 33testcase 'set -- a b; set -- "p$@q"' '2|pa|bq' 34testcase 'set -- a b; set -- "$@q"' '2|a|bq' 35testcase 'set -- a b; set -- "p$@"' '2|pa|b' 36testcase 'set -- a b; set -- p"$@"q' '2|pa|bq' 37testcase 'set -- a b; set -- "$@"q' '2|a|bq' 38testcase 'set -- a b; set -- p"$@"' '2|pa|b' 39testcase 'set -- "" a b; set -- "p$@q"' '3|p|a|bq' 40testcase 'set -- "" a b; set -- "$@q"' '3||a|bq' 41testcase 'set -- "" a b; set -- "p$@"' '3|p|a|b' 42testcase 'set -- "" a b; set -- p"$@"q' '3|p|a|bq' 43testcase 'set -- "" a b; set -- "$@"q' '3||a|bq' 44testcase 'set -- "" a b; set -- p"$@"' '3|p|a|b' 45testcase 'set -- a; set -- p$@q' '1|paq' 46testcase 'set -- a; set -- $@q' '1|aq' 47testcase 'set -- a; set -- p$@' '1|pa' 48testcase 'set -- a; set -- p$@q' '1|paq' 49testcase 'set -- a; set -- $@q' '1|aq' 50testcase 'set -- a; set -- p$@' '1|pa' 51testcase 'set -- a; set -- p$*q' '1|paq' 52testcase 'set -- a; set -- $*q' '1|aq' 53testcase 'set -- a; set -- p$*' '1|pa' 54testcase 'set -- a; set -- p$*q' '1|paq' 55testcase 'set -- a; set -- $*q' '1|aq' 56testcase 'set -- a; set -- p$*' '1|pa' 57testcase 'set -- a; set -- "p$@q"' '1|paq' 58testcase 'set -- a; set -- "$@q"' '1|aq' 59testcase 'set -- a; set -- "p$@"' '1|pa' 60testcase 'set -- a; set -- p"$@"q' '1|paq' 61testcase 'set -- a; set -- "$@"q' '1|aq' 62testcase 'set -- a; set -- p"$@"' '1|pa' 63 64test "x$failures" = x 65