diff options
author | Denys Vlasenko | 2023-06-15 10:07:12 +0200 |
---|---|---|
committer | Denys Vlasenko | 2023-06-15 10:14:43 +0200 |
commit | 5f56a0388271d2de6cf31af1041bdcb3d11029fc (patch) | |
tree | e569191d44b44dcdc87e31c9927374a1ea97c20c /shell/ash_test | |
parent | 3829d8b6758439251fc3e34dcedf5910d039b07d (diff) | |
download | busybox-5f56a0388271d2de6cf31af1041bdcb3d11029fc.zip busybox-5f56a0388271d2de6cf31af1041bdcb3d11029fc.tar.gz |
shell/math: fix parsing of ?: and explain why it's parsed that way
This fixes arith-precedence1.tests.
This breaks arith-ternary2.tests again (we now evaluate variables
on not-taken branches). We need a better logic here anyway:
not only bare variables should not evaluate when not-taken:
1 ? eval_me : do_not_eval
but any (arbitrarily complex) expressions shouldn't
evaluate as well!
1 ? var_is_set=1 : ((var_is_not_set=2,var2*=4))
function old new delta
evaluate_string 1097 1148 +51
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test')
-rw-r--r-- | shell/ash_test/ash-arith/arith-ternary_nested1.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-arith/arith-ternary_nested1.tests | 2 | ||||
-rw-r--r-- | shell/ash_test/ash-arith/arith.right | 2 |
3 files changed, 4 insertions, 1 deletions
diff --git a/shell/ash_test/ash-arith/arith-ternary_nested1.right b/shell/ash_test/ash-arith/arith-ternary_nested1.right new file mode 100644 index 0000000..d803196 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary_nested1.right @@ -0,0 +1 @@ +3:3 diff --git a/shell/ash_test/ash-arith/arith-ternary_nested1.tests b/shell/ash_test/ash-arith/arith-ternary_nested1.tests new file mode 100755 index 0000000..469584b --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary_nested1.tests @@ -0,0 +1,2 @@ +exec 2>&1 +echo 3:$((1?(2?(3):4):5)) diff --git a/shell/ash_test/ash-arith/arith.right b/shell/ash_test/ash-arith/arith.right index 61fcab5..8bc78b8 100644 --- a/shell/ash_test/ash-arith/arith.right +++ b/shell/ash_test/ash-arith/arith.right @@ -92,7 +92,7 @@ ghi ./arith.tests: line 190: arithmetic syntax error 16 16 ./arith.tests: line 195: arithmetic syntax error -./arith.tests: line 196: malformed ?: operator +./arith.tests: line 196: arithmetic syntax error ./arith.tests: line 197: arithmetic syntax error 9 9 ./arith.tests: line 204: arithmetic syntax error |