mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 14:10:38 +08:00
Added error for 2>&1 > lol
This commit is contained in:
@@ -22,7 +22,8 @@ basicChecks = [
|
|||||||
checkRedirectToSame,
|
checkRedirectToSame,
|
||||||
checkShorthandIf,
|
checkShorthandIf,
|
||||||
checkForInDollarStar,
|
checkForInDollarStar,
|
||||||
checkUnquotedDollarAt
|
checkUnquotedDollarAt,
|
||||||
|
checkStderrRedirect
|
||||||
]
|
]
|
||||||
|
|
||||||
modifyMap = modify
|
modifyMap = modify
|
||||||
@@ -155,4 +156,16 @@ checkUnquotedDollarAt (T_NormalWord _ [T_DollarVariable id "@"]) =
|
|||||||
addNoteFor id $ Note ErrorC $ "Add double quotes around $@, otherwise it's just like $* and breaks on spaces"
|
addNoteFor id $ Note ErrorC $ "Add double quotes around $@, otherwise it's just like $* and breaks on spaces"
|
||||||
checkUnquotedDollarAt _ = return ()
|
checkUnquotedDollarAt _ = return ()
|
||||||
|
|
||||||
|
prop_checkStderrRedirect = verify checkStderrRedirect "test 2>&1 > cow"
|
||||||
|
prop_checkStderrRedirect2 = verifyNot checkStderrRedirect "test > cow 2>&1"
|
||||||
|
checkStderrRedirect (T_Redirecting _ [
|
||||||
|
T_FdRedirect id "2" (T_IoFile _ (T_GREATAND _) (T_NormalWord _ [T_Literal _ "1"])),
|
||||||
|
T_FdRedirect _ _ (T_IoFile _ op _)
|
||||||
|
] _) = case op of
|
||||||
|
T_Greater _ -> error
|
||||||
|
T_DGREAT _ -> error
|
||||||
|
_ -> return ()
|
||||||
|
where error = addNoteFor id $ Note ErrorC $ "The order of the 2>&1 and the redirect matters. The 2>&1 has to be last."
|
||||||
|
checkStderrRedirect _ = return ()
|
||||||
|
|
||||||
lt x = trace (show x) x
|
lt x = trace (show x) x
|
||||||
|
1
badcase/twogreaterandone
Normal file
1
badcase/twogreaterandone
Normal file
@@ -0,0 +1 @@
|
|||||||
|
strace foo 2>&1 > allmessages
|
Reference in New Issue
Block a user