Parse empty [ ] conditionals

This commit is contained in:
Vidar Holen
2017-04-16 18:11:00 -07:00
parent 7604e5eb58
commit 5c01b6c7f5
3 changed files with 17 additions and 2 deletions

View File

@@ -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 }) ) |])