Check for calls to `which`.

Favour the builtin `command -v` instead.
This commit is contained in:
Jon Higgs 2018-02-22 15:51:48 +11:00
parent b7a8b090d2
commit e8fc09414a
1 changed files with 4 additions and 0 deletions

View File

@ -91,6 +91,7 @@ commandChecks = [
,checkMvArguments, checkCpArguments, checkLnArguments
,checkFindRedirections
,checkReadExpansions
,checkWhich
]
buildCommandMap :: [CommandCheck] -> Map.Map CommandName (Token -> Analysis)
@ -939,6 +940,9 @@ checkFindRedirections = CommandCheck (Basename "find") f
"Redirection applies to the find command itself. Rewrite to work per action (or move to end)."
_ -> return ()
prop_checkWhich = verify checkWhich "which '.+'"
checkWhich = CommandCheck (Basename "which") $
\t -> info (getId t) 2230 "which is non-standard. Use builtin 'command -v' instead."
return []
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])