From e86c3c67d60c8b240b1693cda7af5079e39e8dce Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 21 Feb 2016 03:02:35 -0500 Subject: Preserve leading backslashes in words --- diff --git a/parsing/lexer.sh b/parsing/lexer.sh index aa72ec1..c856d99 100644 --- a/parsing/lexer.sh +++ b/parsing/lexer.sh @@ -109,7 +109,7 @@ next() continue ;; esac - next_word + next_word \\ return ;; '#') @@ -172,7 +172,7 @@ next() return ;; *) - next_word + next_word '' return ;; esac @@ -327,6 +327,8 @@ next_io() next_word() { + local prev_c="${1}" + shift 1 local res= local word= @@ -337,7 +339,7 @@ next_word() res="${res#*${RS}}" c="${res%%${RS}*}" res="${res#*${RS}}" - word="${res%%${RS}*}" + word="${prev_c}${res%%${RS}*}" # We must advance lineno because scan_word() was run in a subshell. lineno=$((${lineno} + ${ln_off})) diff --git a/parsing/parse.sh b/parsing/parse.sh index ddcdd97..600a247 100644 --- a/parsing/parse.sh +++ b/parsing/parse.sh @@ -660,4 +660,8 @@ try() #try 'foo <<-EOF' "${HT}bar" "${HT}EOF" #try 'foo <