diff options
-rw-r--r-- | parsing/lexer.sh | 21 | ||||
-rw-r--r-- | parsing/parse.sh | 14 |
2 files changed, 30 insertions, 5 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}" } diff --git a/parsing/parse.sh b/parsing/parse.sh index 600a247..c9e8000 100644 --- a/parsing/parse.sh +++ b/parsing/parse.sh @@ -659,9 +659,13 @@ try() #try 'foo <<EOF' 'bar' 'EOF' #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 <<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' +#try '\foo' +try '"foo bar" baz' +try '"foo' +try 'foo\" bar' +try 'foo\' |