Check for globs in test, e.g. [[ -e file* ]]

This commit is contained in:
Vidar Holen 2014-05-25 12:04:18 -07:00
parent 1af23fd131
commit d830a36bc8
1 changed files with 8 additions and 0 deletions

View File

@ -200,6 +200,7 @@ nodeChecks = [
,checkSuspiciousIFS
,checkAliasesUsesArgs
,checkShouldUseGrepQ
,checkTestGlobs
]
@ -2800,3 +2801,10 @@ checkShouldUseGrepQ params t =
T_Pipeline _ _ cmds -> return cmds
_ -> fail "unknown"
isGrep = isSuffixOf "grep"
prop_checkTestGlobs1 = verify checkTestGlobs "[ -e *.mp3 ]"
prop_checkTestGlobs2 = verifyNot checkTestGlobs "[[ $a == *b* ]]"
checkTestGlobs params (TC_Unary _ _ op token) | isGlob token =
err (getId token) 2144 $
op ++ " doesn't work with globs. Use a for loop."
checkTestGlobs _ _ = return ()