Only trigger SC1014 when command is a complete word (fixes #1737)

This commit is contained in:
Vidar Holen 2019-11-03 13:25:46 -08:00
parent e701cf6fad
commit 93eca1cb8e
1 changed files with 2 additions and 0 deletions

View File

@ -437,6 +437,7 @@ readConditionContents single =
readCondContents `attempting` lookAhead (do
pos <- getPosition
s <- readVariableName
spacing1
when (s `elem` commonCommands) $
parseProblemAt pos WarningC 1014 "Use 'if cmd; then ..' to check exit code, or 'if [[ $(cmd) == .. ]]' to check output.")
@ -911,6 +912,7 @@ prop_readCondition21 = isOk readCondition "[[ $1 =~ ^(a\\ b)$ ]]"
prop_readCondition22 = isOk readCondition "[[ $1 =~ \\.a\\.(\\.b\\.)\\.c\\. ]]"
prop_readCondition23 = isOk readCondition "[[ -v arr[$var] ]]"
prop_readCondition24 = isWarning readCondition "[[ 1 == 2 ]]]"
prop_readCondition25 = isOk readCondition "[[ lex.yy.c -ot program.l ]]"
readCondition = called "test expression" $ do
opos <- getPosition
start <- startSpan