diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-14 11:05:48 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-14 11:07:30 +0200 |
commit | 46dccd2ec0eafd850b2168d4dfe4e74949fd3424 (patch) | |
tree | cb853ae6459c7fd7c48fbcaa42d46056fe77c03f /shell/ash_test | |
parent | a02450ff0bfa45618e72fc7103ea3a8f0e7fff80 (diff) | |
download | busybox-w32-46dccd2ec0eafd850b2168d4dfe4e74949fd3424.tar.gz busybox-w32-46dccd2ec0eafd850b2168d4dfe4e74949fd3424.tar.bz2 busybox-w32-46dccd2ec0eafd850b2168d4dfe4e74949fd3424.zip |
shell/math: fix nested ?: and do not parse variables in not-taken branch
Fixes arith-ternary1.tests and arith-ternary_nested.tests
function old new delta
evaluate_string 1043 1101 +58
arith_apply 1087 1137 +50
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 108/0) Total: 108 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test')
-rw-r--r-- | shell/ash_test/ash-arith/arith-ternary1.right | 3 | ||||
-rwxr-xr-x | shell/ash_test/ash-arith/arith-ternary1.tests | 7 | ||||
-rw-r--r-- | shell/ash_test/ash-arith/arith-ternary2.right | 4 | ||||
-rwxr-xr-x | shell/ash_test/ash-arith/arith-ternary2.tests | 7 | ||||
-rw-r--r-- | shell/ash_test/ash-arith/arith-ternary_nested.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-arith/arith-ternary_nested.tests | 2 |
6 files changed, 12 insertions, 12 deletions
diff --git a/shell/ash_test/ash-arith/arith-ternary1.right b/shell/ash_test/ash-arith/arith-ternary1.right index c968f1181..6b751d7b8 100644 --- a/shell/ash_test/ash-arith/arith-ternary1.right +++ b/shell/ash_test/ash-arith/arith-ternary1.right | |||
@@ -1,5 +1,2 @@ | |||
1 | 42:42 | 1 | 42:42 |
2 | a=0 | 2 | a=0 |
3 | 6:6 | ||
4 | a=b=+err+ | ||
5 | b=6 | ||
diff --git a/shell/ash_test/ash-arith/arith-ternary1.tests b/shell/ash_test/ash-arith/arith-ternary1.tests index 5a54e34b6..3532ce54d 100755 --- a/shell/ash_test/ash-arith/arith-ternary1.tests +++ b/shell/ash_test/ash-arith/arith-ternary1.tests | |||
@@ -3,10 +3,3 @@ a=0 | |||
3 | # The not-taken branch should not evaluate | 3 | # The not-taken branch should not evaluate |
4 | echo 42:$((1 ? 42 : (a+=2))) | 4 | echo 42:$((1 ? 42 : (a+=2))) |
5 | echo "a=$a" | 5 | echo "a=$a" |
6 | |||
7 | a='b=+err+' | ||
8 | b=5 | ||
9 | # The not-taken branch should not even parse variables | ||
10 | echo 6:$((0 ? a : ++b)) | ||
11 | echo "a=$a" | ||
12 | echo "b=$b" | ||
diff --git a/shell/ash_test/ash-arith/arith-ternary2.right b/shell/ash_test/ash-arith/arith-ternary2.right index aa54bd925..a549b1b5c 100644 --- a/shell/ash_test/ash-arith/arith-ternary2.right +++ b/shell/ash_test/ash-arith/arith-ternary2.right | |||
@@ -1 +1,3 @@ | |||
1 | 5:5 | 1 | 6:6 |
2 | a=b=+err+ | ||
3 | b=6 | ||
diff --git a/shell/ash_test/ash-arith/arith-ternary2.tests b/shell/ash_test/ash-arith/arith-ternary2.tests index eefc8e7ce..cb3163932 100755 --- a/shell/ash_test/ash-arith/arith-ternary2.tests +++ b/shell/ash_test/ash-arith/arith-ternary2.tests | |||
@@ -1,2 +1,7 @@ | |||
1 | exec 2>&1 | 1 | exec 2>&1 |
2 | echo 5:$((1?2?3?4?5:6:7:8:9)) | 2 | a='b=+err+' |
3 | b=5 | ||
4 | # The not-taken branch should not parse variables | ||
5 | echo 6:$((0 ? a : ++b)) | ||
6 | echo "a=$a" | ||
7 | echo "b=$b" | ||
diff --git a/shell/ash_test/ash-arith/arith-ternary_nested.right b/shell/ash_test/ash-arith/arith-ternary_nested.right new file mode 100644 index 000000000..aa54bd925 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary_nested.right | |||
@@ -0,0 +1 @@ | |||
5:5 | |||
diff --git a/shell/ash_test/ash-arith/arith-ternary_nested.tests b/shell/ash_test/ash-arith/arith-ternary_nested.tests new file mode 100755 index 000000000..eefc8e7ce --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary_nested.tests | |||
@@ -0,0 +1,2 @@ | |||
1 | exec 2>&1 | ||
2 | echo 5:$((1?2?3?4?5:6:7:8:9)) | ||