Permalink
Browse files

Nailing down the behavior of compound expressions in [

  • Loading branch information...
Andy Chu
Andy Chu committed Aug 10, 2017
1 parent 32df376 commit 1d170327e2488ec78a2b7f0543246114d4cd97b0
Showing with 19 additions and 1 deletion.
  1. +17 −0 spec/test-builtin.test.sh
  2. +2 −1 test/spec.sh
View
@@ -1,4 +1,8 @@
#!/usr/bin/env bash
#
# NOTES:
# - osh is using the external binary.
# - because ! -a -o ( ) are the same, we can share logic with [[.
### empty string is false. Equivalent to -n.
test 'a' && echo true
@@ -9,3 +13,16 @@ test '' || echo false
test -n 'a' && echo true
test -n '' || echo false
# stdout-json: "true\nfalse\n"
### ! -a -o
[ -z '' -a ! -z x ] && echo true
# stdout: true
### ( )
[ -z '' -a '(' ! -z x ')' ] && echo true
# stdout: true
### ( ) ! -a -o with system version of [
command [ --version
command [ -z '' -a '(' ! -z x ')' ] && echo true
# stdout: true
View
@@ -239,7 +239,8 @@ if_() {
# NOTE: osh uses external test! But that's OK for now.
test-builtin() {
sh-spec spec/test-builtin.test.sh ${REF_SHELLS[@]} $OSH "$@"
sh-spec spec/test-builtin.test.sh --osh-failures-allowed 1 \
${REF_SHELLS[@]} $OSH "$@"
}
builtins() {

0 comments on commit 1d17032

Please sign in to comment.