Don't mention arrays in SC2089 in sh/dash (fixes #1014)

This commit is contained in:
Vidar Holen 2019-04-27 16:22:01 -07:00
parent bf1003eae3
commit 9470b9dc31
2 changed files with 8 additions and 2 deletions

View File

@ -1822,12 +1822,16 @@ checkQuotesInLiterals params t =
&& not (isQuoteFree parents expr) && not (isQuoteFree parents expr)
&& not (squashesQuotes expr) && not (squashesQuotes expr)
then [ then [
makeComment WarningC (fromJust assignment) 2089 makeComment WarningC (fromJust assignment) 2089 $
"Quotes/backslashes will be treated literally. Use an array.", "Quotes/backslashes will be treated literally. " ++ suggestion,
makeComment WarningC (getId expr) 2090 makeComment WarningC (getId expr) 2090
"Quotes/backslashes in this variable will not be respected." "Quotes/backslashes in this variable will not be respected."
] ]
else []) else [])
suggestion =
if supportsArrays (shellType params)
then "Use an array."
else "Rewrite using set/\"$@\" or functions."
prop_checkFunctionsUsedExternally1 = prop_checkFunctionsUsedExternally1 =

View File

@ -940,5 +940,7 @@ getOpts flagTokenizer string cmd = process flags
more <- process rest2 more <- process rest2
return $ (flag1, token1) : more return $ (flag1, token1) : more
supportsArrays shell = shell == Bash || shell == Ksh
return [] return []
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |]) runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])