mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-14 00:53:15 -07:00
Don't warn about expr when using <, > and friends
This commit is contained in:
parent
c26c2b8536
commit
727d940e10
1 changed files with 7 additions and 2 deletions
|
@ -451,9 +451,14 @@ checkUuoc _ _ = return ()
|
||||||
prop_checkNeedlessCommands = verify checkNeedlessCommands "foo=$(expr 3 + 2)"
|
prop_checkNeedlessCommands = verify checkNeedlessCommands "foo=$(expr 3 + 2)"
|
||||||
prop_checkNeedlessCommands2 = verify checkNeedlessCommands "foo=`echo \\`expr 3 + 2\\``"
|
prop_checkNeedlessCommands2 = verify checkNeedlessCommands "foo=`echo \\`expr 3 + 2\\``"
|
||||||
prop_checkNeedlessCommands3 = verifyNot checkNeedlessCommands "foo=$(expr foo : regex)"
|
prop_checkNeedlessCommands3 = verifyNot checkNeedlessCommands "foo=$(expr foo : regex)"
|
||||||
checkNeedlessCommands _ cmd@(T_SimpleCommand id _ _) |
|
prop_checkNeedlessCommands4 = verifyNot checkNeedlessCommands "foo=$(expr foo \\< regex)"
|
||||||
cmd `isCommand` "expr" && (not $ ":" `elem` deadSimple cmd) =
|
checkNeedlessCommands _ cmd@(T_SimpleCommand id _ args) |
|
||||||
|
cmd `isCommand` "expr" && (not $ any (`elem` words) exceptions) =
|
||||||
style id 2003 "expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]]."
|
style id 2003 "expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]]."
|
||||||
|
where
|
||||||
|
-- These operators are hard to replicate in POSIX
|
||||||
|
exceptions = [ ":", "<", ">", "<=", ">=" ]
|
||||||
|
words = mapMaybe getLiteralString args
|
||||||
checkNeedlessCommands _ _ = return ()
|
checkNeedlessCommands _ _ = return ()
|
||||||
|
|
||||||
prop_checkPipePitfalls3 = verify checkPipePitfalls "ls | grep -v mp3"
|
prop_checkPipePitfalls3 = verify checkPipePitfalls "ls | grep -v mp3"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue