diff options
author | jilles <jilles@FreeBSD.org> | 2010-04-04 16:48:33 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-04-04 16:48:33 +0000 |
commit | ca9540f0dcc7ca3a4a9fe641bdbc0e69de32c895 (patch) | |
tree | fd0e37ff789a604b64be7cf26c839116e8f1a040 /tools | |
parent | 85f39c5eeb30f26b1450102f6e6f92b2777cb38a (diff) | |
download | FreeBSD-src-ca9540f0dcc7ca3a4a9fe641bdbc0e69de32c895.zip FreeBSD-src-ca9540f0dcc7ca3a4a9fe641bdbc0e69de32c895.tar.gz |
sh: Add test for nested arithmetic substitution.
Pre-r206145 sh changes nested arithmetic substitution to parentheses, which
is not always correct, as exercised by this test.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/bin/sh/expansion/arith5.0 | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/expansion/arith5.0 b/tools/regression/bin/sh/expansion/arith5.0 new file mode 100644 index 0000000..d0f2331 --- /dev/null +++ b/tools/regression/bin/sh/expansion/arith5.0 @@ -0,0 +1,17 @@ +# $FreeBSD$ + +failures=0 + +check() { + if [ "$2" != "$3" ]; then + failures=$((failures+1)) + echo "For $1, expected $3 actual $2" + fi +} + +unset a +check '$((1+${a:-$((7+2))}))' "$((1+${a:-$((7+2))}))" 10 +check '$((1+${a:=$((2+2))}))' "$((1+${a:=$((2+2))}))" 5 +check '$a' "$a" 4 + +exit $((failures != 0)) |