diff options
author | P. J. McDermott <pj@pehjota.net> | 2016-02-21 03:19:13 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2016-02-21 03:19:13 (EST) |
commit | 84bc61b8d596f3d342980e98b9c580d655ea0778 (patch) | |
tree | c6151065926df4dcbe8859751526150f85687da3 /parsing/lexer.sh | |
parent | e86c3c67d60c8b240b1693cda7af5079e39e8dce (diff) | |
download | eggshell-84bc61b8d596f3d342980e98b9c580d655ea0778.zip eggshell-84bc61b8d596f3d342980e98b9c580d655ea0778.tar.gz eggshell-84bc61b8d596f3d342980e98b9c580d655ea0778.tar.bz2 |
Improve backslash and quote handling in words
Diffstat (limited to 'parsing/lexer.sh')
-rw-r--r-- | parsing/lexer.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/parsing/lexer.sh b/parsing/lexer.sh index c856d99..53af926 100644 --- a/parsing/lexer.sh +++ b/parsing/lexer.sh @@ -429,6 +429,23 @@ scan_word() 'command substitution not supported' break ;; + \\) + word="${word}${c}" + lgetc + case "${c}" in '') + # Bash, ksh93, mksh, and zsh ignore a + # backslash at the end of a file, but + # dash and BusyBox ash include it in the + # word. To help with script + # portability, we'll throw an error + # (which is a reasonable thing to do + # anyway). + synerr 'Unexpected end of file %s' \ + 'after "\"' + ;; + esac + word="${word}${c}" + ;; \') word="${word}${c}" while :; do @@ -461,6 +478,10 @@ scan_word() lgetc done + if ${quoted}; then + synerr 'Unterminated quoted string' + fi + printf "%d${RS}%c${RS}%s" ${lines} "${c}" "${word}" } |