Permalink
Browse files

Fix bug I introduced in last commit with ${empty:-} (no quotes).

Fixes issue #41.
  • Loading branch information...
Andy Chu
Andy Chu committed Sep 23, 2017
1 parent 8da6ccb commit 5d44441f0597d76d2831b351efa88cdd4b436c18
Showing with 9 additions and 3 deletions.
  1. +3 −2 osh/word_parse.py
  2. +6 −1 spec/var-sub-quote.test.sh
View
@@ -149,8 +149,9 @@ def _ReadVarOpArg(self, arg_lex_mode, eof_type=Id.Undefined_Tok,
# potential problem of not having spids.
#
# NOTE: empty_ok is False only for the PatSub pattern, which means we'll
# return a CompoundWord(parts=[]), which fails later.
if not w.parts and empty_ok:
# return a CompoundWord with no parts, which is explicitly checked with a
# custom error message.
if not w.parts and arg_lex_mode == LexMode.VS_ARG_DQ and empty_ok:
w.parts.append(ast.SingleQuotedPart())
return w
@@ -14,11 +14,16 @@
# LexState.OUTER. If we have "${}", then it's parsed as LexState.DQ. That
# makes sense I guess. Vim's syntax highlighting is throwing me off.
### :- with empty alternative
### "${empty:-}"
empty=
argv.py "${empty:-}"
# stdout: ['']
### ${empty:-}
empty=
argv.py ${empty:-}
# stdout: []
### :-
empty=''
argv.py ${empty:-a} ${Unset:-b}

0 comments on commit 5d44441

Please sign in to comment.