1 2e= s='foo' 3failures='' 4ok='' 5 6testcase() { 7 code="$1" 8 expected="$2" 9 oIFS="$IFS" 10 eval "$code" 11 IFS='|' 12 result="$#|$*" 13 IFS="$oIFS" 14 if [ "x$result" = "x$expected" ]; then 15 ok=x$ok 16 else 17 failures=x$failures 18 echo "For $code, expected $expected actual $result" 19 fi 20} 21 22testcase 'set -- ${s+a b}' '2|a|b' 23testcase 'set -- ${e:-a b}' '2|a|b' 24 25test "x$failures" = x 26