From e978b31de0d40fe2054327f9adfc78b9d3fc0e1d Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 20 Feb 2016 13:55:44 -0500 Subject: Don't eat the first token after a command substitution --- (limited to 'parsing') diff --git a/parsing/lexer.sh b/parsing/lexer.sh index 6e2c4f4..928021e 100644 --- a/parsing/lexer.sh +++ b/parsing/lexer.sh @@ -410,17 +410,8 @@ scan_wordexp() res="${res#*${RS}}" toks="${res%%${RS}*}" lineno=${ln_off} - wordexp="\$(${STX}${toks}${ETX}" - # Get ")" - case "${c}" in - ')') - wordexp="${wordexp}${c}" - pgetc - ;; - *) - synerr 'Missing ")"' - ;; - esac + wordexp="\$(${STX}${toks}${ETX})" + # ")" is recognized in parse_sub(). ;; esac ;; diff --git a/parsing/parse.sh b/parsing/parse.sh index da9b2e5..d9fb6a1 100644 --- a/parsing/parse.sh +++ b/parsing/parse.sh @@ -600,14 +600,19 @@ parse_sub() if ${complete} && ! accept T_EOF; then synexp '' fi + if ! ${complete}; then + case "${tok%${US}*}" in + T_RPAREN) + ;; + *) + synerr 'Missing ")"' + ;; + esac + fi get_lineno printf '%c' "${RS}" - if accept T_RPAREN; then - printf ')' - else - get_lexer_char - fi + get_lexer_char printf '%c' "${RS}" get_tokens @@ -675,4 +680,7 @@ try() #try 'case foo in bar) baz;; (qux) quux;; quux);; esac' #try 'foo bar ( baz )' try 'foo $(bar)' +try 'foo $(bar); baz' +try 'foo $(bar)' 'baz' +try 'foo $(bar) baz' #try 'foo $((1 + 1))' -- cgit v0.9.1