mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-07 13:31:36 -07:00
SC2240: Warn about . script args..
in sh/dash (fixes #1373)
This commit is contained in:
parent
de95c376ea
commit
2827b35696
2 changed files with 13 additions and 0 deletions
|
@ -92,6 +92,7 @@ commandChecks = [
|
|||
,checkWhich
|
||||
,checkSudoRedirect
|
||||
,checkSudoArgs
|
||||
,checkSourceArgs
|
||||
]
|
||||
|
||||
buildCommandMap :: [CommandCheck] -> Map.Map CommandName (Token -> Analysis)
|
||||
|
@ -1008,5 +1009,16 @@ checkSudoArgs = CommandCheck (Basename "sudo") f
|
|||
-- This mess is why ShellCheck prefers not to know.
|
||||
parseOpts = getBsdOpts "vAknSbEHPa:g:h:p:u:c:T:r:"
|
||||
|
||||
prop_checkSourceArgs1 = verify checkSourceArgs "#!/bin/sh\n. script arg"
|
||||
prop_checkSourceArgs2 = verifyNot checkSourceArgs "#!/bin/sh\n. script"
|
||||
prop_checkSourceArgs3 = verifyNot checkSourceArgs "#!/bin/bash\n. script arg"
|
||||
checkSourceArgs = CommandCheck (Exactly ".") f
|
||||
where
|
||||
f t = whenShell [Sh, Dash] $
|
||||
case arguments t of
|
||||
(file:arg1:_) -> warn (getId arg1) 2240 $
|
||||
"The dot command does not support arguments in sh/dash. Set them as variables."
|
||||
_ -> return ()
|
||||
|
||||
return []
|
||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue