mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-09-19 18:19:22 +08:00
Don't warn about uuoc for cat -n and similar.
This commit is contained in:
@@ -454,12 +454,14 @@ prop_checkUuoc2 = verifyNot checkUuoc "cat * | grep bar"
|
|||||||
prop_checkUuoc3 = verify checkUuoc "cat $var | grep bar"
|
prop_checkUuoc3 = verify checkUuoc "cat $var | grep bar"
|
||||||
prop_checkUuoc4 = verifyNot checkUuoc "cat $var"
|
prop_checkUuoc4 = verifyNot checkUuoc "cat $var"
|
||||||
prop_checkUuoc5 = verifyNot checkUuoc "cat \"$@\""
|
prop_checkUuoc5 = verifyNot checkUuoc "cat \"$@\""
|
||||||
|
prop_checkUuoc6 = verifyNot checkUuoc "cat -n | grep bar"
|
||||||
checkUuoc _ (T_Pipeline _ _ (T_Redirecting _ _ cmd:_:_)) =
|
checkUuoc _ (T_Pipeline _ _ (T_Redirecting _ _ cmd:_:_)) =
|
||||||
checkCommand "cat" (const f) cmd
|
checkCommand "cat" (const f) cmd
|
||||||
where
|
where
|
||||||
f [word] = unless (mayBecomeMultipleArgs word) $
|
f [word] = unless (mayBecomeMultipleArgs word || isOption word) $
|
||||||
style (getId word) 2002 "Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead."
|
style (getId word) 2002 "Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead."
|
||||||
f _ = return ()
|
f _ = return ()
|
||||||
|
isOption word = "-" `isPrefixOf` onlyLiteralString word
|
||||||
checkUuoc _ _ = return ()
|
checkUuoc _ _ = return ()
|
||||||
|
|
||||||
prop_checkNeedlessCommands = verify checkNeedlessCommands "foo=$(expr 3 + 2)"
|
prop_checkNeedlessCommands = verify checkNeedlessCommands "foo=$(expr 3 + 2)"
|
||||||
|
Reference in New Issue
Block a user