Handle escaped expansions in heredocs

Fixes #28
This commit is contained in:
Max Brunsfeld 2018-10-18 11:12:43 -07:00
parent cdbc8863cd
commit 46cf157ad8
2 changed files with 19 additions and 0 deletions

View File

@ -169,3 +169,15 @@ wc -l $tmpfile
(command_name (word)) (command_name (word))
(word) (word)
(simple_expansion (variable_name)))) (simple_expansion (variable_name))))
======================================
Heredocs with escaped expansions
======================================
cat << EOF
DEV_NAME=\$(lsblk)
EOF
---
(program (redirected_statement (command (command_name (word))) (heredoc_redirect (heredoc_start))) (heredoc_body))

7
src/scanner.cc vendored
View File

@ -61,6 +61,13 @@ struct Scanner {
return did_advance; return did_advance;
} }
case '\\': {
did_advance = true;
advance(lexer);
advance(lexer);
break;
}
case '$': { case '$': {
lexer->result_symbol = middle_type; lexer->result_symbol = middle_type;
return did_advance; return did_advance;