Permalink
Browse files
Fix test for closing ] in [.
- Loading branch information...
Showing
with
18 additions
and
3 deletions.
-
+1
−1
core/test_builtin.py
-
+2
−0
doc/osh-quick-ref-toc.txt
-
+15
−2
spec/builtin-test.test.sh
|
|
@@ -119,7 +119,7 @@ def Test(argv, need_right_bracket): |
|
|
The only difference between test and [ is that [ needs a matching ].
|
|
|
"""
|
|
|
if need_right_bracket:
|
|
|
if argv[-1] != ']':
|
|
|
if not argv or argv[-1] != ']':
|
|
|
util.error('[: missing closing ]')
|
|
|
return 2
|
|
|
del argv[-1]
|
|
|
|
|
|
@@ -32,6 +32,7 @@ X [Conditional] switch match if-expr ( |
|
|
X [Iteration] for-expr ( while-expr (
|
|
|
X [Grouping] proc func lazy pure do { shell {
|
|
|
X [Context] with-cd with-redir with-env with-vars with-file
|
|
|
with-logger
|
|
|
X [Concurrency] fork
|
|
|
X [Redirects] multiline-string '''_""" file-descriptor !0
|
|
|
|
|
|
@@ -157,6 +158,7 @@ X [xargs] each |
|
|
|
|
|
OIL LIBRARIES
|
|
|
|
|
|
X [Builtin Procs] log die
|
|
|
X [Builtin Funcs] shEvalArith() shEvalWord()
|
|
|
X [getopts] ?
|
|
|
X [Testing] ?
|
|
|
|
|
|
@@ -65,16 +65,29 @@ test -n x ] |
|
|
echo status=$?
|
|
|
test -n x y
|
|
|
echo status=$?
|
|
|
# stdout-json: "status=2\nstatus=2\n"
|
|
|
## STDOUT:
|
|
|
status=2
|
|
|
status=2
|
|
|
## END
|
|
|
|
|
|
### ] syntax errors
|
|
|
[
|
|
|
echo status=$?
|
|
|
test # not a syntax error
|
|
|
echo status=$?
|
|
|
[ -n x # missing ]
|
|
|
echo status=$?
|
|
|
[ -n x ] y # extra arg after ]
|
|
|
echo status=$?
|
|
|
[ -n x y # extra arg
|
|
|
echo status=$?
|
|
|
# stdout-json: "status=2\nstatus=2\nstatus=2\n"
|
|
|
## STDOUT:
|
|
|
status=2
|
|
|
status=1
|
|
|
status=2
|
|
|
status=2
|
|
|
status=2
|
|
|
## END
|
|
|
|
|
|
### -n
|
|
|
test -n 'a' && echo true
|
|
|
|
0 comments on commit
2192156