Improve code for warning about escaped single quotes.

This commit is contained in:
Vidar Holen 2016-12-28 21:51:28 -08:00
parent 5669702362
commit df3cc70658
1 changed files with 7 additions and 10 deletions

View File

@ -1309,19 +1309,16 @@ readExtglobPart = do
readSingleEscaped = do readSingleEscaped = do
pos <- getPosition
s <- backslash s <- backslash
let attempt level code p msg = do { try $ parseNote level code msg; x <- p; return [s,x]; } x <- lookAhead anyChar
do { case x of
x <- lookAhead singleQuote; '\'' -> parseProblemAt pos InfoC 1003 "Want to escape a single quote? echo 'This is how it'\''s done'.";
parseProblem InfoC 1003 "Are you trying to escape that single quote? echo 'You'\\''re doing it wrong'."; '\n' -> parseProblemAt pos InfoC 1004 "This backslash+linefeed is literal. Break outside single quotes if you just want to break the line."
return [s]; _ -> return ()
}
<|> 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]
return [s]
readDoubleEscaped = do readDoubleEscaped = do
bs <- backslash bs <- backslash