Warn about 'export $foo'
This commit is contained in:
parent
b1843c520f
commit
8894333556
|
@ -207,6 +207,7 @@ nodeChecks = [
|
||||||
,checkMaskedReturns
|
,checkMaskedReturns
|
||||||
,checkInjectableFindSh
|
,checkInjectableFindSh
|
||||||
,checkReadWithoutR
|
,checkReadWithoutR
|
||||||
|
,checkExportedExpansions
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -3461,6 +3462,18 @@ checkReadWithoutR _ t@(T_SimpleCommand {}) | t `isUnqualifiedCommand` "read" =
|
||||||
info (getId t) 2162 "read without -r will mangle backslashes."
|
info (getId t) 2162 "read without -r will mangle backslashes."
|
||||||
checkReadWithoutR _ _ = return ()
|
checkReadWithoutR _ _ = return ()
|
||||||
|
|
||||||
|
prop_checkExportedExpansions1 = verify checkExportedExpansions "export $foo"
|
||||||
|
prop_checkExportedExpansions2 = verify checkExportedExpansions "export \"$foo\""
|
||||||
|
prop_checkExportedExpansions3 = verifyNot checkExportedExpansions "export foo"
|
||||||
|
checkExportedExpansions _ = checkUnqualifiedCommand "export" (const check)
|
||||||
|
where
|
||||||
|
check = mapM_ checkForVariables
|
||||||
|
checkForVariables f =
|
||||||
|
case getWordParts f of
|
||||||
|
[t@(T_DollarBraced {})] ->
|
||||||
|
warn (getId t) 2163 "Exporting an expansion rather than a variable."
|
||||||
|
_ -> return ()
|
||||||
|
|
||||||
|
|
||||||
return []
|
return []
|
||||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||||
|
|
Loading…
Reference in New Issue