aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2012-02-23 15:58:27 +0800
committerMu Qiao <qiaomuf@gentoo.org>2012-02-23 16:20:16 +0800
commitf4bdbb24bdbcb12655005202dec2fc6e216f0ed3 (patch)
tree2c4efa82db56b6be2c8770f017df085ab46dff71 /scripts
parentWalker: support shortcut in keyword test (diff)
downloadlibbash-f4bdbb24bdbcb12655005202dec2fc6e216f0ed3.tar.gz
libbash-f4bdbb24bdbcb12655005202dec2fc6e216f0ed3.tar.bz2
libbash-f4bdbb24bdbcb12655005202dec2fc6e216f0ed3.zip
Parser&Walker: respect precedence in builtin test
Builtin test does not support shortcut capability. Tests are added to verify that.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/test_expr.bash8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/test_expr.bash b/scripts/test_expr.bash
index 6ae7246..f8e7c03 100644
--- a/scripts/test_expr.bash
+++ b/scripts/test_expr.bash
@@ -61,3 +61,11 @@ i=1
[[ a == b && $((i=1)) ]] || echo $i # i should still be 0
i=1
[[ a == a && $((i=0)) ]] && echo $i # i should still be 0
+[ -n "a" -o -n "" -a -n "" ] && echo true
+# builtin test doesn't support shortcut
+i=1
+[ 1 -eq 2 -o $((i=0)) ] && echo $i # i should be 0 now
+[ 1 -eq 1 -o $((i=1)) ] && echo $i # i should still be 1
+[ 1 -eq 2 -a $((i=1)) ] || echo $i # i should still be 1
+i=1
+[ 1 -eq 1 -a $((i=0)) ] && echo $i # i should still be 0