aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test/hush-arith
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-01-28 20:13:33 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-01-28 20:13:33 +0100
commitf19e3c1c6c96e3c709ac732ff70c586521f792d3 (patch)
treef2b16759f1eae8ac09205f0fb29f822d70610a36 /shell/hush_test/hush-arith
parent675d24aeaff29dbce6dc116a4b7c9f6026ed5069 (diff)
downloadbusybox-w32-f19e3c1c6c96e3c709ac732ff70c586521f792d3.tar.gz
busybox-w32-f19e3c1c6c96e3c709ac732ff70c586521f792d3.tar.bz2
busybox-w32-f19e3c1c6c96e3c709ac732ff70c586521f792d3.zip
shell: handle $((NUM++...) like bash does. Closes 10706
function old new delta evaluate_string 680 729 +49 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush_test/hush-arith')
-rw-r--r--shell/hush_test/hush-arith/arith-postinc.right5
-rwxr-xr-xshell/hush_test/hush-arith/arith-postinc.tests5
-rw-r--r--shell/hush_test/hush-arith/arith.right4
-rwxr-xr-xshell/hush_test/hush-arith/arith2.sub12
4 files changed, 20 insertions, 6 deletions
diff --git a/shell/hush_test/hush-arith/arith-postinc.right b/shell/hush_test/hush-arith/arith-postinc.right
new file mode 100644
index 000000000..c95ce02bf
--- /dev/null
+++ b/shell/hush_test/hush-arith/arith-postinc.right
@@ -0,0 +1,5 @@
11 1
21 1
31 1
41 1
5Ok:0
diff --git a/shell/hush_test/hush-arith/arith-postinc.tests b/shell/hush_test/hush-arith/arith-postinc.tests
new file mode 100755
index 000000000..3fd9bfed5
--- /dev/null
+++ b/shell/hush_test/hush-arith/arith-postinc.tests
@@ -0,0 +1,5 @@
1echo 1 $((0++1))
2echo 1 $((0--1))
3x=-1; echo 1 $((0-$x))
4x=+1; echo 1 $((0+$x))
5echo Ok:$?
diff --git a/shell/hush_test/hush-arith/arith.right b/shell/hush_test/hush-arith/arith.right
index 8a201fb3b..c48e468a5 100644
--- a/shell/hush_test/hush-arith/arith.right
+++ b/shell/hush_test/hush-arith/arith.right
@@ -135,6 +135,10 @@ hush: arithmetic syntax error
135hush: arithmetic syntax error 135hush: arithmetic syntax error
1365 5 1365 5
1371 1 1371 1
1386 6
1392 2
1403 3
1411 1
1384 4 1424 4
1390 0 1430 0
140hush: arithmetic syntax error 144hush: arithmetic syntax error
diff --git a/shell/hush_test/hush-arith/arith2.sub b/shell/hush_test/hush-arith/arith2.sub
index f7e3c9235..9105059db 100755
--- a/shell/hush_test/hush-arith/arith2.sub
+++ b/shell/hush_test/hush-arith/arith2.sub
@@ -23,14 +23,14 @@
23echo 5 $(( 4 + ++a )) 23echo 5 $(( 4 + ++a ))
24echo 1 $a 24echo 1 $a
25 25
26# ash doesn't handle it right... 26# this is treated as 4 + ++a
27#ash# echo 6 $(( 4+++a )) 27echo 6 $(( 4+++a ))
28#ash# echo 2 $a 28echo 2 $a
29 a=2 29 a=2
30 30
31# ash doesn't handle it right... 31# this is treated as 4 - --a
32#ash# echo 3 $(( 4---a )) 32echo 3 $(( 4---a ))
33#ash# echo 1 $a 33echo 1 $a
34 a=1 34 a=1
35 35
36echo 4 $(( 4 - -- a )) 36echo 4 $(( 4 - -- a ))