Skip to content

Commit

Permalink
Fix shell heredoc token
Browse files Browse the repository at this point in the history
A heredoc token cannot contain space. If we don't add this rule, we will
have a wrong coloration when the heredoc is piped into a second command.

FIX: In Shell mode, don't allow spaces in heredoc tokens.

Co-authored-by: Samir ALI CHERIF <samir@cyberwatch.fr>
  • Loading branch information
Slokilla and Samir ALI CHERIF committed Jul 7, 2023
1 parent 265edad commit 9fd24d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mode/shell.js
Expand Up @@ -55,9 +55,9 @@ function tokenBase(stream, state) {
}
if (ch == "<") {
if (stream.match("<<")) return "operator"
var heredoc = stream.match(/^<-?\s*['"]?([^'"]*)['"]?/)
var heredoc = stream.match(/^<-?\s*(?:['"]([^'"]*)['"]|([^'"\s]*))/)
if (heredoc) {
state.tokens.unshift(tokenHeredoc(heredoc[1]))
state.tokens.unshift(tokenHeredoc(heredoc[1] || heredoc[2]))
return 'string.special'
}
}
Expand Down

0 comments on commit 9fd24d9

Please sign in to comment.