mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 15:27:02 +08:00
Parse empty [ ] conditionals
This commit is contained in:
@@ -163,6 +163,7 @@ nodeChecks = [
|
||||
,checkSplittingInArrays
|
||||
,checkRedirectionToNumber
|
||||
,checkGlobAsCommand
|
||||
,checkEmptyCondition
|
||||
]
|
||||
|
||||
|
||||
@@ -2819,5 +2820,11 @@ checkGlobAsCommand _ t = case t of
|
||||
warn (getId first) 2211 "This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?"
|
||||
_ -> return ()
|
||||
|
||||
prop_checkEmptyCondition1 = verify checkEmptyCondition "if [ ]; then ..; fi"
|
||||
prop_checkEmptyCondition2 = verifyNot checkEmptyCondition "[ foo -o bar ]"
|
||||
checkEmptyCondition _ t = case t of
|
||||
TC_Empty id _ -> style id 2212 "Use 'false' instead of empty [/[[ conditionals."
|
||||
_ -> return ()
|
||||
|
||||
return []
|
||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||
|
Reference in New Issue
Block a user