diff --git a/ShellCheck/Checks/Commands.hs b/ShellCheck/Checks/Commands.hs index e9964e0..21a309e 100644 --- a/ShellCheck/Checks/Commands.hs +++ b/ShellCheck/Checks/Commands.hs @@ -90,6 +90,7 @@ commandChecks = [ ,checkExportedExpansions ,checkAliasesUsesArgs ,checkAliasesExpandEarly + ,checkUnsetGlobs ] buildCommandMap :: [CommandCheck] -> Map.Map CommandName (Token -> Analysis) @@ -589,5 +590,14 @@ checkAliasesExpandEarly = CommandCheck (Exactly "alias") (f . arguments) checkArg _ = return () +prop_checkUnsetGlobs1 = verify checkUnsetGlobs "unset foo[1]" +prop_checkUnsetGlobs2 = verifyNot checkUnsetGlobs "unset foo" +checkUnsetGlobs = CommandCheck (Exactly "unset") (mapM_ check . arguments) + where + check arg = + when (isGlob arg) $ + warn (getId arg) 2184 "Quote arguments to unset so they're not glob expanded." + + return [] runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])