Skip to content

Commit

Permalink
Improve code for warning about escaped single quotes.
Browse files Browse the repository at this point in the history
  • Loading branch information
koalaman committed Dec 29, 2016
1 parent 5669702 commit df3cc70
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions ShellCheck/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,19 +1309,16 @@ readExtglobPart = do


readSingleEscaped = do
pos <- getPosition
s <- backslash
let attempt level code p msg = do { try $ parseNote level code msg; x <- p; return [s,x]; }
x <- lookAhead anyChar

do {
x <- lookAhead singleQuote;
parseProblem InfoC 1003 "Are you trying to escape that single quote? echo 'You'\\''re doing it wrong'.";
return [s];
}
<|> attempt InfoC 1004 linefeed "You don't break lines with \\ in single quotes, it results in literal backslash-linefeed."
<|> do
x <- anyChar
return [s,x]
case x of
'\'' -> parseProblemAt pos InfoC 1003 "Want to escape a single quote? echo 'This is how it'\''s done'.";
'\n' -> parseProblemAt pos InfoC 1004 "This backslash+linefeed is literal. Break outside single quotes if you just want to break the line."
_ -> return ()

return [s]

readDoubleEscaped = do
bs <- backslash
Expand Down

0 comments on commit df3cc70

Please sign in to comment.