1 2e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' 3h='##' 4failures='' 5ok='' 6 7testcase() { 8 code="$1" 9 expected="$2" 10 oIFS="$IFS" 11 eval "$code" 12 IFS='|' 13 result="$#|$*" 14 IFS="$oIFS" 15 if [ "x$result" = "x$expected" ]; then 16 ok=x$ok 17 else 18 failures=x$failures 19 echo "For $code, expected $expected actual $result" 20 fi 21} 22 23testcase 'set -- ${e:-"{x}"}' '1|{x}' 24testcase 'set -- "${e:-"{x}"}"' '1|{x}' 25testcase 'set -- ${h+"{x}"}' '1|{x}' 26testcase 'set -- "${h+"{x}"}"' '1|{x}' 27testcase 'set -- ${h:-"{x}"}' '1|##' 28testcase 'set -- "${h:-"{x}"}"' '1|##' 29 30test "x$failures" = x 31