1# This tests if the cmdsubst optimization is still used if possible. 2 3failures='' 4ok='' 5 6testcase() { 7 code="$1" 8 9 unset v 10 eval "pid=\$(dummy=$code echo \$(\$SH -c echo\ \\\$PPID))" 11 12 if [ "$pid" = "$$" ]; then 13 ok=x$ok 14 else 15 failures=x$failures 16 echo "Failure for $code" 17 fi 18} 19 20unset v 21w=1 22testcase '$w' 23testcase '1${w+1}' 24testcase '1${w-1}' 25testcase '1${v+1}' 26testcase '1${v-1}' 27testcase '1${w:+1}' 28testcase '1${w:-1}' 29testcase '1${v:+1}' 30testcase '1${v:-1}' 31testcase '${w?}' 32testcase '${w:?}' 33testcase '${w#x}' 34testcase '${w##x}' 35testcase '${w%x}' 36testcase '${w%%x}' 37 38testcase '$((w))' 39testcase '$(((w+4)*2/3))' 40testcase '$((w==1))' 41testcase '$((w>=0 && w<=5 && w!=2))' 42testcase '$((${#w}))' 43testcase '$((${#IFS}))' 44testcase '$((${#w}>=1))' 45testcase '$(($$))' 46testcase '$(($#))' 47testcase '$(($?))' 48 49testcase '$(: $((w=4)))' 50testcase '$(: ${v=2})' 51 52test "x$failures" = x 53