diff --git a/corpus/literals.txt b/corpus/literals.txt index 37fdc53..7827371 100644 --- a/corpus/literals.txt +++ b/corpus/literals.txt @@ -306,3 +306,16 @@ a+=(foo "bar" $(baz)) (word) (string) (command_substitution (command (command_name (word))))))) + +============================== +Escaped characters in strings +============================== + +echo -ne "\033k$1\033\\" > /dev/stderr + +--- + +(program + (redirected_statement + (command (command_name (word)) (word) (string (simple_expansion (variable_name)))) + (file_redirect (word)))) diff --git a/grammar.js b/grammar.js index d8825d1..6b47c1a 100644 --- a/grammar.js +++ b/grammar.js @@ -425,7 +425,7 @@ module.exports = grammar({ '"' ), - _string_content: $ => token(prec(-1, /([^"`$]|\\.)+/)), + _string_content: $ => token(prec(-1, /([^"`$\\]|\\(.|\n))+/)), array: $ => seq( '(',