mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-22 06:13:54 -07:00
Fix issue #1733 (False negative in SC2155)
This commit is contained in:
parent
60f75e5b8a
commit
be0d0247b1
1 changed files with 3 additions and 2 deletions
|
@ -2788,11 +2788,12 @@ prop_checkMaskedReturns2 = verify checkMaskedReturns "declare a=$(false)"
|
|||
prop_checkMaskedReturns3 = verify checkMaskedReturns "declare a=\"`false`\""
|
||||
prop_checkMaskedReturns4 = verifyNot checkMaskedReturns "declare a; a=$(false)"
|
||||
prop_checkMaskedReturns5 = verifyNot checkMaskedReturns "f() { local -r a=$(false); }"
|
||||
checkMaskedReturns _ t@(T_SimpleCommand id _ (cmd:rest)) = potentially $ do
|
||||
checkMaskedReturns _ t@(T_SimpleCommand id preopts (cmd:rest)) = potentially $ do
|
||||
name <- getCommandName t
|
||||
guard $ name `elem` ["declare", "export"]
|
||||
|| name == "local" && "r" `notElem` map snd (getAllFlags t)
|
||||
return $ mapM_ checkArgs rest
|
||||
|| not (null preopts)
|
||||
return $ mapM_ checkArgs (preopts ++ rest)
|
||||
where
|
||||
checkArgs (T_Assignment id _ _ _ word) | any hasReturn $ getWordParts word =
|
||||
warn id 2155 "Declare and assign separately to avoid masking return values."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue