Skip to content

Commit 8d5e3a8

Browse files
authored
Merge pull request #1123 from jonhiggs/check-for-which-usage
Check for calls to `which`.
2 parents 34e0fa5 + e8fc094 commit 8d5e3a8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ShellCheck/Checks/Commands.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ commandChecks = [
9191
,checkMvArguments, checkCpArguments, checkLnArguments
9292
,checkFindRedirections
9393
,checkReadExpansions
94+
,checkWhich
9495
]
9596

9697
buildCommandMap :: [CommandCheck] -> Map.Map CommandName (Token -> Analysis)
@@ -939,6 +940,9 @@ checkFindRedirections = CommandCheck (Basename "find") f
939940
"Redirection applies to the find command itself. Rewrite to work per action (or move to end)."
940941
_ -> return ()
941942

943+
prop_checkWhich = verify checkWhich "which '.+'"
944+
checkWhich = CommandCheck (Basename "which") $
945+
\t -> info (getId t) 2230 "which is non-standard. Use builtin 'command -v' instead."
942946

943947
return []
944948
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])

0 commit comments

Comments
 (0)