From f653362b18f9428accfb75b74890d63d771a3e6d Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 15 Aug 2015 13:50:09 -0700 Subject: [PATCH] Warn about bashism [^bar]. --- ShellCheck/Analytics.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index f8874f7..26bf353 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -680,6 +680,7 @@ prop_checkBashisms23= verify checkBashisms "trap mything err int" prop_checkBashisms24= verifyNot checkBashisms "trap mything int term" prop_checkBashisms25= verify checkBashisms "cat < /dev/tcp/host/123" prop_checkBashisms26= verify checkBashisms "trap mything ERR SIGTERM" +prop_checkBashisms27= verify checkBashisms "echo *[^0-9]*" checkBashisms _ = bashism where errMsg id s = err id 2040 $ "In sh, " ++ s ++ " not supported, even when sh is actually bash." @@ -710,6 +711,8 @@ checkBashisms _ = bashism where file = onlyLiteralString word isNetworked = any (`isPrefixOf` file) ["/dev/tcp", "/dev/udp"] + bashism (T_Glob id str) | "[^" `isInfixOf` str = + warnMsg id "^ in place of ! in glob bracket expressions is" bashism t@(TA_Expansion id _) | isBashism = warnMsg id $ fromJust str ++ " is"