summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-02-21 03:02:35 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-02-21 03:02:35 (EST)
commite86c3c67d60c8b240b1693cda7af5079e39e8dce (patch)
treead96b84b2978ed99353b5c48d68db816a70bae8a
parent7d41cd8c37232fb86e75fec705b3fda2b5ecb562 (diff)
downloadeggshell-e86c3c67d60c8b240b1693cda7af5079e39e8dce.zip
eggshell-e86c3c67d60c8b240b1693cda7af5079e39e8dce.tar.gz
eggshell-e86c3c67d60c8b240b1693cda7af5079e39e8dce.tar.bz2
Preserve leading backslashes in words
-rw-r--r--parsing/lexer.sh8
-rw-r--r--parsing/parse.sh4
2 files changed, 9 insertions, 3 deletions
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 <<EOF' '$(bar)' 'EOF'
try 'foo <<E"O"F' '$(bar)' 'EOF'
+try 'foo <<"EOF"' '$(bar)' 'EOF'
+try 'foo <<E\OF' '$(bar)' 'EOF'
+try 'foo <<\EOF' '$(bar)' 'EOF'
#try 'foo <<EOF1; bar <<EOF2' 'baz' 'EOF1' 'qux' 'EOF2'
+try '\foo'