mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-16 10:03:08 -07:00
Supress SC2093 when execfail is set (fixes #3178)
This commit is contained in:
parent
8ff0c5be7a
commit
72af76f443
2 changed files with 9 additions and 1 deletions
|
@ -1896,7 +1896,9 @@ prop_checkSpuriousExec8 = verifyNot checkSpuriousExec "exec {origout}>&1- >tmp.l
|
|||
prop_checkSpuriousExec9 = verify checkSpuriousExec "for file in rc.d/*; do exec \"$file\"; done"
|
||||
prop_checkSpuriousExec10 = verifyNot checkSpuriousExec "exec file; r=$?; printf >&2 'failed\n'; return $r"
|
||||
prop_checkSpuriousExec11 = verifyNot checkSpuriousExec "exec file; :"
|
||||
checkSpuriousExec _ = doLists
|
||||
prop_checkSpuriousExec12 = verifyNot checkSpuriousExec "#!/bin/bash\nshopt -s execfail; exec foo; exec bar; echo 'Error'; exit 1;"
|
||||
prop_checkSpuriousExec13 = verify checkSpuriousExec "#!/bin/dash\nshopt -s execfail; exec foo; exec bar; echo 'Error'; exit 1;"
|
||||
checkSpuriousExec params t = when (not $ hasExecfail params) $ doLists t
|
||||
where
|
||||
doLists (T_Script _ _ cmds) = doList cmds False
|
||||
doLists (T_BraceGroup _ cmds) = doList cmds False
|
||||
|
|
|
@ -89,6 +89,8 @@ data Parameters = Parameters {
|
|||
hasSetE :: Bool,
|
||||
-- Whether this script has 'set -o pipefail' anywhere.
|
||||
hasPipefail :: Bool,
|
||||
-- Whether this script has 'shopt -s execfail' anywhere.
|
||||
hasExecfail :: Bool,
|
||||
-- A linear (bad) analysis of data flow
|
||||
variableFlow :: [StackData],
|
||||
-- A map from Id to Token
|
||||
|
@ -226,6 +228,10 @@ makeParameters spec = params
|
|||
BusyboxSh -> isOptionSet "pipefail" root
|
||||
Sh -> True
|
||||
Ksh -> isOptionSet "pipefail" root,
|
||||
hasExecfail =
|
||||
case shellType params of
|
||||
Bash -> isOptionSet "execfail" root
|
||||
_ -> False,
|
||||
shellTypeSpecified = isJust (asShellType spec) || isJust (asFallbackShell spec),
|
||||
idMap = getTokenMap root,
|
||||
parentMap = getParentTree root,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue