mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-19 13:00:54 -07:00
Allow 'su --command=something'
Previously, 'su --command=something' would result in SC2117 although it is the official long version of 'su -c something'.
This commit is contained in:
parent
f1bdda54cb
commit
a0c2fa4b2b
1 changed files with 6 additions and 1 deletions
|
@ -607,9 +607,11 @@ prop_checkInteractiveSu1 = verify checkInteractiveSu "su; rm file; su $USER"
|
|||
prop_checkInteractiveSu2 = verify checkInteractiveSu "su foo; something; exit"
|
||||
prop_checkInteractiveSu3 = verifyNot checkInteractiveSu "echo rm | su foo"
|
||||
prop_checkInteractiveSu4 = verifyNot checkInteractiveSu "su root < script"
|
||||
prop_checkInteractiveSu5 = verify checkInteractiveSu "su -c something"
|
||||
prop_checkInteractiveSu6 = verify checkInteractiveSu "su --command=something"
|
||||
checkInteractiveSu = CommandCheck (Basename "su") f
|
||||
where
|
||||
f cmd = when (length (arguments cmd) <= 1) $ do
|
||||
f cmd = when (noCommandArgPresent (arguments cmd)) $ do
|
||||
path <- getPathM cmd
|
||||
when (all undirected path) $
|
||||
info (getId cmd) 2117
|
||||
|
@ -620,6 +622,9 @@ checkInteractiveSu = CommandCheck (Basename "su") f
|
|||
undirected (T_Redirecting _ (_:_) _) = False
|
||||
undirected _ = True
|
||||
|
||||
noCommandArgPresent = not . any isCommandArg . map (getLiteralStringDef "_")
|
||||
isCommandArg arg = arg == "-c" && "--command=" `isPrefixOf` arg
|
||||
|
||||
|
||||
-- This is hard to get right without properly parsing ssh args
|
||||
prop_checkSshCmdStr1 = verify checkSshCommandString "ssh host \"echo $PS1\""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue