mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-10 23:32:57 -07:00
Add SC2238 about redirections to command names
This commit is contained in:
parent
1a6ae4f19e
commit
3e2cb26119
2 changed files with 11 additions and 0 deletions
|
@ -169,6 +169,7 @@ nodeChecks = [
|
|||
,checkForLoopGlobVariables
|
||||
,checkSubshelledTests
|
||||
,checkInvertedStringTest
|
||||
,checkRedirectionToCommand
|
||||
]
|
||||
|
||||
|
||||
|
@ -3027,6 +3028,15 @@ checkInvertedStringTest _ t =
|
|||
_ -> return ()
|
||||
_ -> return ()
|
||||
|
||||
prop_checkRedirectionToCommand1 = verify checkRedirectionToCommand "ls > rm"
|
||||
prop_checkRedirectionToCommand2 = verifyNot checkRedirectionToCommand "ls > 'rm'"
|
||||
prop_checkRedirectionToCommand3 = verifyNot checkRedirectionToCommand "ls > myfile"
|
||||
checkRedirectionToCommand _ t =
|
||||
case t of
|
||||
T_IoFile _ _ (T_NormalWord id [T_Literal _ str]) | str `elem` commonCommands ->
|
||||
unless (str == "file") $ -- This would be confusing
|
||||
warn id 2238 "Redirecting to/from command name instead of file. Did you want pipes/xargs (or quote to ignore)?"
|
||||
_ -> return ()
|
||||
|
||||
return []
|
||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue