diff options
-rw-r--r-- | shell/ash_test/ash-arith/arith-ternary_nested2.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-arith/arith-ternary_nested2.tests | 2 | ||||
-rw-r--r-- | shell/hush_test/hush-arith/arith-ternary_nested2.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-arith/arith-ternary_nested2.tests | 2 | ||||
-rw-r--r-- | shell/math.c | 12 |
5 files changed, 9 insertions, 9 deletions
diff --git a/shell/ash_test/ash-arith/arith-ternary_nested2.right b/shell/ash_test/ash-arith/arith-ternary_nested2.right new file mode 100644 index 000000000..d80319695 --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary_nested2.right | |||
@@ -0,0 +1 @@ | |||
3:3 | |||
diff --git a/shell/ash_test/ash-arith/arith-ternary_nested2.tests b/shell/ash_test/ash-arith/arith-ternary_nested2.tests new file mode 100755 index 000000000..e8b8a9e1a --- /dev/null +++ b/shell/ash_test/ash-arith/arith-ternary_nested2.tests | |||
@@ -0,0 +1,2 @@ | |||
1 | exec 2>&1 | ||
2 | echo 3:$((0?1:2?3:4?5:6?7:8)) | ||
diff --git a/shell/hush_test/hush-arith/arith-ternary_nested2.right b/shell/hush_test/hush-arith/arith-ternary_nested2.right new file mode 100644 index 000000000..d80319695 --- /dev/null +++ b/shell/hush_test/hush-arith/arith-ternary_nested2.right | |||
@@ -0,0 +1 @@ | |||
3:3 | |||
diff --git a/shell/hush_test/hush-arith/arith-ternary_nested2.tests b/shell/hush_test/hush-arith/arith-ternary_nested2.tests new file mode 100755 index 000000000..e8b8a9e1a --- /dev/null +++ b/shell/hush_test/hush-arith/arith-ternary_nested2.tests | |||
@@ -0,0 +1,2 @@ | |||
1 | exec 2>&1 | ||
2 | echo 3:$((0?1:2?3:4?5:6?7:8)) | ||
diff --git a/shell/math.c b/shell/math.c index f6aa02ac2..8d0c9dea7 100644 --- a/shell/math.c +++ b/shell/math.c | |||
@@ -840,15 +840,9 @@ evaluate_string(arith_state_t *math_state, const char *expr) | |||
840 | if (prev_prec < prec | 840 | if (prev_prec < prec |
841 | || (prev_prec == prec && is_right_associative(prec)) | 841 | || (prev_prec == prec && is_right_associative(prec)) |
842 | ) { | 842 | ) { |
843 | /* Unless a?b?c:d:... and we are at the second : */ | 843 | /* ...x~y@: push @ on opstack */ |
844 | if (op != TOK_CONDITIONAL_SEP | 844 | opstackptr++; /* undo removal of ~ op */ |
845 | || prev_op != TOK_CONDITIONAL_SEP | 845 | goto push_op; |
846 | ) { | ||
847 | /* ...x~y@: push @ on opstack */ | ||
848 | opstackptr++; /* undo removal of ~ op */ | ||
849 | goto push_op; | ||
850 | } | ||
851 | /* else: a?b?c:d:. Evaluate b?c:d, replace it on stack with result. Then repeat */ | ||
852 | } | 846 | } |
853 | /* else: ...x~y@. Evaluate x~y, replace it on stack with result. Then repeat */ | 847 | /* else: ...x~y@. Evaluate x~y, replace it on stack with result. Then repeat */ |
854 | } | 848 | } |