From 9470b9dc315c4b868aa174624ec649f4e1bcd478 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 27 Apr 2019 16:22:01 -0700 Subject: [PATCH] Don't mention arrays in SC2089 in sh/dash (fixes #1014) --- src/ShellCheck/Analytics.hs | 8 ++++++-- src/ShellCheck/AnalyzerLib.hs | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 163a3cc..f89df9a 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -1822,12 +1822,16 @@ checkQuotesInLiterals params t = && not (isQuoteFree parents expr) && not (squashesQuotes expr) then [ - makeComment WarningC (fromJust assignment) 2089 - "Quotes/backslashes will be treated literally. Use an array.", + makeComment WarningC (fromJust assignment) 2089 $ + "Quotes/backslashes will be treated literally. " ++ suggestion, makeComment WarningC (getId expr) 2090 "Quotes/backslashes in this variable will not be respected." ] else []) + suggestion = + if supportsArrays (shellType params) + then "Use an array." + else "Rewrite using set/\"$@\" or functions." prop_checkFunctionsUsedExternally1 = diff --git a/src/ShellCheck/AnalyzerLib.hs b/src/ShellCheck/AnalyzerLib.hs index 361ce8b..01fcc8f 100644 --- a/src/ShellCheck/AnalyzerLib.hs +++ b/src/ShellCheck/AnalyzerLib.hs @@ -940,5 +940,7 @@ getOpts flagTokenizer string cmd = process flags more <- process rest2 return $ (flag1, token1) : more +supportsArrays shell = shell == Bash || shell == Ksh + return [] runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])