From 5649a9aa1ce56c0cfdcab088983f2d3a4cb32a4c Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 21 Feb 2016 20:33:22 -0500 Subject: eshtrans/frontend: Fix line numbers --- (limited to 'eshtrans') diff --git a/eshtrans/frontend/lexer.esh b/eshtrans/frontend/lexer.esh index 46ba310..92c806c 100644 --- a/eshtrans/frontend/lexer.esh +++ b/eshtrans/frontend/lexer.esh @@ -458,6 +458,7 @@ scan_word() # We must advance lineno because scan_wordexp() # was run in a subshell. lineno=$((${lineno} + ${ln_off})) + lines=$((${lines} + ${ln_off})) word="${word}${res}" # scan_wordexp() leaves behind an unused # character, so we should skip the lgetc() call @@ -583,7 +584,8 @@ scan_wordexp() res="${res#*${RS}}" c="${res%%${RS}*}" res="${res#*${RS}}" - lineno=${ln_off} + ln_off=$((${ln_off} - ${lineno})) + lineno=$((${lineno} + ${ln_off})) wordexp="\$(${SOH}C${STX}${res}" wordexp="${wordexp}${ETX})" # ")" is recognized in run_sublexer(). diff --git a/eshtrans/main.esh b/eshtrans/main.esh index b0bcf53..0a0b929 100644 --- a/eshtrans/main.esh +++ b/eshtrans/main.esh @@ -116,6 +116,8 @@ main() #try 'foo 2>bar' #try '2>bar' #try '2 foo' +dbg=true +try 'foo $(bar \' 'baz \' 'qux) &&' # Line number testing - sh_codegen "$(esh_parse "${1}" <"${1}")" +# sh_codegen "$(esh_parse "${1}" <"${1}")" } -- cgit v0.9.1