Add SC1133: Warn when a line starts with |/||/&& (fixes #1359)
This commit is contained in:
parent
b815242506
commit
df0a0d41fa
|
@ -5,6 +5,7 @@
|
||||||
- SC2236/SC2237: Suggest -n/-z instead of ! -z/-n
|
- SC2236/SC2237: Suggest -n/-z instead of ! -z/-n
|
||||||
- SC2238: Warn when redirecting to a known command name, e.g. ls > rm
|
- SC2238: Warn when redirecting to a known command name, e.g. ls > rm
|
||||||
- SC2239: Warn if the shebang is not an absolute path, e.g. #!bin/sh
|
- SC2239: Warn if the shebang is not an absolute path, e.g. #!bin/sh
|
||||||
|
- SC1133: Better diagnostics when starting a line with |/||/&&
|
||||||
### Changed
|
### Changed
|
||||||
- Most warnings now have useful end positions
|
- Most warnings now have useful end positions
|
||||||
- SC1117 about unknown double-quoted escape sequences has been retired
|
- SC1117 about unknown double-quoted escape sequences has been retired
|
||||||
|
|
|
@ -1911,7 +1911,13 @@ readHereString = called "here string" $ do
|
||||||
word <- readNormalWord
|
word <- readNormalWord
|
||||||
return $ T_HereString id word
|
return $ T_HereString id word
|
||||||
|
|
||||||
readNewlineList = many1 ((linefeed <|> carriageReturn) `thenSkip` spacing)
|
readNewlineList =
|
||||||
|
many1 ((linefeed <|> carriageReturn) `thenSkip` spacing) <* checkBadBreak
|
||||||
|
where
|
||||||
|
checkBadBreak = optional $ do
|
||||||
|
pos <- getPosition
|
||||||
|
try $ lookAhead (oneOf "|&") -- |, || or &&
|
||||||
|
parseProblemAt pos ErrorC 1133 "Unexpected start of line. If breaking lines, |/||/&& should be at the end of the previous one."
|
||||||
readLineBreak = optional readNewlineList
|
readLineBreak = optional readNewlineList
|
||||||
|
|
||||||
prop_readSeparator1 = isWarning readScript "a &; b"
|
prop_readSeparator1 = isWarning readScript "a &; b"
|
||||||
|
@ -2300,7 +2306,7 @@ readSubshell = called "explicit subshell" $ do
|
||||||
allspacing
|
allspacing
|
||||||
list <- readCompoundList
|
list <- readCompoundList
|
||||||
allspacing
|
allspacing
|
||||||
char ')' <|> fail ") closing the subshell"
|
char ')' <|> fail "Expected ) closing the subshell"
|
||||||
id <- endSpan start
|
id <- endSpan start
|
||||||
return $ T_Subshell id list
|
return $ T_Subshell id list
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue