From f53205fcfa3664184b4a8f18b12f4911f2a948d3 Mon Sep 17 00:00:00 2001 From: jilles Date: Sat, 24 Aug 2013 20:06:00 +0000 Subject: sh: Reject ++ and -- in arithmetic. POSIX does not require ++ and -- in arithmetic. It is probably more useful to reject them than to treat ++x and --x as x silently. Note that the behaviour of increment and decrement can be obtained via (x+=1), ((x+=1)-1), (x-=1) and ((x-=1)+1). PR: bin/176444 --- tools/regression/bin/sh/expansion/arith13.0 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tools/regression/bin/sh/expansion/arith13.0 (limited to 'tools/regression') diff --git a/tools/regression/bin/sh/expansion/arith13.0 b/tools/regression/bin/sh/expansion/arith13.0 new file mode 100644 index 0000000..207e488 --- /dev/null +++ b/tools/regression/bin/sh/expansion/arith13.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ +# Pre-increment and pre-decrement in arithmetic expansion are not in POSIX. +# Require either an error or a correct implementation. + +! (eval 'x=4; [ $((++x)) != 5 ] || [ $x != 5 ]') 2>/dev/null && +! (eval 'x=2; [ $((--x)) != 1 ] || [ $x != 1 ]') 2>/dev/null -- cgit v1.1