From 38730b344f7027fa89097ca660300802842a18aa Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 21 Feb 2016 12:19:00 -0500 Subject: eshtrans/frontend: Don't eat char after wordexp in arithmetic Before: Trying script: $(($foo + 1)) Tokens: T_FNAME$(($foo+ 1))T_NEWLINET_EOF Token: function name "$(($foo+ 1))" Token: newline Token: end of file Generated code: $(($foo+ 1)) Trying script: $((1 + $foo)) stdin:1: Syntax error: Arithmetic expansion: ")" unexpected FAIL After: Trying script: $(($foo + 1)) Tokens: T_FNAME$(($foo + 1))T_NEWLINET_EOF Token: function name "$(($foo + 1))" Token: newline Token: end of file Generated code: $(($foo + 1)) Trying script: $((1 + $foo)) Tokens: T_FNAME$((1 + $foo))T_NEWLINET_EOF Token: function name "$((1 + $foo))" Token: newline Token: end of file Generated code: $((1 + $foo)) --- (limited to 'eshtrans/frontend') diff --git a/eshtrans/frontend/lexer.esh b/eshtrans/frontend/lexer.esh index d904aa0..6775bbc 100644 --- a/eshtrans/frontend/lexer.esh +++ b/eshtrans/frontend/lexer.esh @@ -783,8 +783,8 @@ scan_wordexp_arith() arith='' paren_lvl=0 + lgetc while :; do - lgetc case "${c}" in '') synerr 'end of file unexpected (%s)' \ @@ -823,11 +823,13 @@ scan_wordexp_arith() # was run in a subshell. lineno=$((${lineno} + ${ln_off})) arith="${arith}${sub_wordexp}" + continue ;; *) arith="${arith}${c}" ;; esac + lgetc done } -- cgit v0.9.1