diff options
Diffstat (limited to 'shell/hush_test')
7 files changed, 23 insertions, 11 deletions
diff --git a/shell/hush_test/hush-arith/arith-precedence1.right b/shell/hush_test/hush-arith/arith-precedence1.right new file mode 100644 index 0000000..3f9320a --- /dev/null +++ b/shell/hush_test/hush-arith/arith-precedence1.right @@ -0,0 +1,4 @@ +4:4 +4:4 +4:4 +4:4 diff --git a/shell/hush_test/hush-arith/arith-precedence1.tests b/shell/hush_test/hush-arith/arith-precedence1.tests new file mode 100755 index 0000000..bfef052 --- /dev/null +++ b/shell/hush_test/hush-arith/arith-precedence1.tests @@ -0,0 +1,15 @@ +exec 2>&1 +# bash documentation says that precedence order is: +# ... +# expr ? expr1 : expr2 +# = *= /= %= += -= <<= >>= &= ^= |= +# exprA , exprB +# but in practice, the rules for expr1 and expr2 are different: +# assignments and commas in expr1 have higher precedence than :?, +# but in expr2 they haven't: +# "v ? 1,2 : 3,4" is parsed as "(v ? (1,2) : 3),4" +# "v ? a=2 : b=4" is parsed as "(v ? (a=1) : b)=4" (thus, this is a syntax error) +echo 4:$((0 ? 1,2 : 3,4)) +echo 4:$((1 ? 1,2 : 3,4)) +echo 4:"$((0 ? 1,2 : 3,4))" +echo 4:"$((1 ? 1,2 : 3,4))" diff --git a/shell/hush_test/hush-arith/arith-ternary2.right b/shell/hush_test/hush-arith/arith-ternary2.right deleted file mode 100644 index a549b1b..0000000 --- a/shell/hush_test/hush-arith/arith-ternary2.right +++ /dev/null @@ -1,3 +0,0 @@ -6:6 -a=b=+err+ -b=6 diff --git a/shell/hush_test/hush-arith/arith-ternary2.tests b/shell/hush_test/hush-arith/arith-ternary2.tests deleted file mode 100755 index cb31639..0000000 --- a/shell/hush_test/hush-arith/arith-ternary2.tests +++ /dev/null @@ -1,7 +0,0 @@ -exec 2>&1 -a='b=+err+' -b=5 -# The not-taken branch should not parse variables -echo 6:$((0 ? a : ++b)) -echo "a=$a" -echo "b=$b" diff --git a/shell/hush_test/hush-arith/arith-ternary_nested1.right b/shell/hush_test/hush-arith/arith-ternary_nested1.right new file mode 100644 index 0000000..d803196 --- /dev/null +++ b/shell/hush_test/hush-arith/arith-ternary_nested1.right @@ -0,0 +1 @@ +3:3 diff --git a/shell/hush_test/hush-arith/arith-ternary_nested1.tests b/shell/hush_test/hush-arith/arith-ternary_nested1.tests new file mode 100755 index 0000000..469584b --- /dev/null +++ b/shell/hush_test/hush-arith/arith-ternary_nested1.tests @@ -0,0 +1,2 @@ +exec 2>&1 +echo 3:$((1?(2?(3):4):5)) diff --git a/shell/hush_test/hush-arith/arith.right b/shell/hush_test/hush-arith/arith.right index a861229..df8154f 100644 --- a/shell/hush_test/hush-arith/arith.right +++ b/shell/hush_test/hush-arith/arith.right @@ -94,7 +94,7 @@ ghi hush: arithmetic syntax error 16 16 hush: arithmetic syntax error -hush: malformed ?: operator +hush: arithmetic syntax error hush: arithmetic syntax error 9 9 hush: arithmetic syntax error |