Added check for A=foo | grep bar
This commit is contained in:
parent
0ca6d0f6cc
commit
a8715d2d5f
|
@ -64,6 +64,7 @@ basicChecks = [
|
||||||
,checkEcho
|
,checkEcho
|
||||||
,checkConstantIfs
|
,checkConstantIfs
|
||||||
,checkTrAZ
|
,checkTrAZ
|
||||||
|
,checkPipedAssignment
|
||||||
]
|
]
|
||||||
|
|
||||||
modifyMap = modify
|
modifyMap = modify
|
||||||
|
@ -135,6 +136,15 @@ checkEcho (T_Pipeline id [a, b]) =
|
||||||
checkEcho _ = return ()
|
checkEcho _ = return ()
|
||||||
checkEchoSedRe = mkRegex "^s(.)(.*)\\1(.*)\\1g?$"
|
checkEchoSedRe = mkRegex "^s(.)(.*)\\1(.*)\\1g?$"
|
||||||
|
|
||||||
|
|
||||||
|
prop_checkPipedAssignment1 = verify checkPipedAssignment "A=ls | grep foo"
|
||||||
|
prop_checkPipedAssignment2 = verifyNot checkPipedAssignment "A=foo cmd | grep foo"
|
||||||
|
prop_checkPipedAssignment3 = verifyNot checkPipedAssignment "A=foo"
|
||||||
|
checkPipedAssignment (T_Pipeline _ (T_Redirecting _ _ (T_SimpleCommand id (_:_) []):_:_)) =
|
||||||
|
warn id "If you wanted to assign the output of the pipeline, use a=$(b | c)"
|
||||||
|
checkPipedAssignment _ = return ()
|
||||||
|
|
||||||
|
|
||||||
prop_checkUuoc = verify checkUuoc "cat foo | grep bar"
|
prop_checkUuoc = verify checkUuoc "cat foo | grep bar"
|
||||||
checkUuoc (T_Pipeline _ (T_Redirecting _ _ f@(T_SimpleCommand id _ _):_:_)) =
|
checkUuoc (T_Pipeline _ (T_Redirecting _ _ f@(T_SimpleCommand id _ _):_:_)) =
|
||||||
case deadSimple f of ["cat", _] -> style id "Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead."
|
case deadSimple f of ["cat", _] -> style id "Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead."
|
||||||
|
|
Loading…
Reference in New Issue