From e9bba2f75a848086c37fc0776ef0f1bf72c121c8 Mon Sep 17 00:00:00 2001 From: Vidar Holen <spam@vidarholen.net> Date: Sat, 25 Jan 2014 14:30:25 -0800 Subject: [PATCH] Don't warn about comma separation in for f in {a,b} --- ShellCheck/Analytics.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index deac5e5..b3db44a 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -540,6 +540,7 @@ prop_checkForInQuoted2a = verifyNot checkForInQuoted "for f in *.mp3; do echo fo prop_checkForInQuoted2b = verify checkForInQuoted "for f in \"*.mp3\"; do echo foo; done" prop_checkForInQuoted3 = verify checkForInQuoted "for f in 'find /'; do true; done" prop_checkForInQuoted4 = verify checkForInQuoted "for f in 1,2,3; do true; done" +prop_checkForInQuoted4a = verifyNot checkForInQuoted "for f in foo{1,2,3}; do true; done" prop_checkForInQuoted5 = verify checkForInQuoted "for f in ls; do true; done" checkForInQuoted (T_ForIn _ f [T_NormalWord _ [word@(T_DoubleQuoted id list)]] _) = when (any (\x -> willSplit x && not (isMagicInQuotes x)) list @@ -549,7 +550,8 @@ checkForInQuoted (T_ForIn _ f [T_NormalWord _ [T_SingleQuoted id s]] _) = warn id 2041 $ "This is a literal string. To run as a command, use $(" ++ s ++ ")." checkForInQuoted (T_ForIn _ f [T_NormalWord _ [T_Literal id s]] _) = if ',' `elem` s - then warn id 2042 $ "Use spaces, not commas, to separate loop elements." + then when (not $ '{' `elem` s) $ + warn id 2042 $ "Use spaces, not commas, to separate loop elements." else warn id 2043 $ "This loop will only run once, with " ++ f ++ "='" ++ s ++ "'." checkForInQuoted _ = return ()