Permalink
Browse files
Nailing down the behavior of compound expressions in [
- Loading branch information...
Showing
with
19 additions
and
1 deletion.
-
+17
−0
spec/test-builtin.test.sh
-
+2
−1
test/spec.sh
|
|
@@ -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
|
|
|
@@ -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