mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-22 14:23:53 -07:00
Disable SC2155 for portage files
This idiom is extremely common in Gentoo: In tensorflow-1.9.0_rc1.ebuild line 400: export GCC_HOST_COMPILER_PATH="$(which $(tc-getBUILD_CC))" ^--------------------^ SC2155: Declare and assign separately to avoid masking return values. Gentoo shell scripts don't run under `set -e`, and no one ever runs code like `if export ...`, so this warning doesn't help with ebuilds.
This commit is contained in:
parent
f6e4bc828f
commit
a313b48ca6
1 changed files with 5 additions and 3 deletions
|
@ -2745,10 +2745,12 @@ prop_checkMaskedReturns2 = verify checkMaskedReturns "declare a=$(false)"
|
||||||
prop_checkMaskedReturns3 = verify checkMaskedReturns "declare a=\"`false`\""
|
prop_checkMaskedReturns3 = verify checkMaskedReturns "declare a=\"`false`\""
|
||||||
prop_checkMaskedReturns4 = verifyNot checkMaskedReturns "declare a; a=$(false)"
|
prop_checkMaskedReturns4 = verifyNot checkMaskedReturns "declare a; a=$(false)"
|
||||||
prop_checkMaskedReturns5 = verifyNot checkMaskedReturns "f() { local -r a=$(false); }"
|
prop_checkMaskedReturns5 = verifyNot checkMaskedReturns "f() { local -r a=$(false); }"
|
||||||
checkMaskedReturns _ t@(T_SimpleCommand id _ (cmd:rest)) = potentially $ do
|
prop_checkMaskedReturns6 = verifyNot checkMaskedReturns "#shellcheck shell=portage\ndeclare a=$(false)"
|
||||||
|
checkMaskedReturns params t@(T_SimpleCommand id _ (cmd:rest)) = potentially $ do
|
||||||
name <- getCommandName t
|
name <- getCommandName t
|
||||||
guard $ name `elem` ["declare", "export"]
|
guard $ (name `elem` ["declare", "export"]
|
||||||
|| name == "local" && "r" `notElem` map snd (getAllFlags t)
|
|| name == "local" && "r" `notElem` map snd (getAllFlags t))
|
||||||
|
&& (not $ isPortageBuild params)
|
||||||
return $ mapM_ checkArgs rest
|
return $ mapM_ checkArgs rest
|
||||||
where
|
where
|
||||||
checkArgs (T_Assignment id _ _ _ word) | any hasReturn $ getWordParts word =
|
checkArgs (T_Assignment id _ _ _ word) | any hasReturn $ getWordParts word =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue