SC2095: Also warn if the command is backgrounded

This commit is contained in:
Vidar Holen 2020-10-28 13:36:10 -07:00
parent 61b7dd610d
commit 65044c2568
1 changed files with 2 additions and 0 deletions

View File

@ -2361,6 +2361,7 @@ prop_checkWhileReadPitfalls11 = verifyNot checkWhileReadPitfalls "while read foo
prop_checkWhileReadPitfalls12 = verifyNot checkWhileReadPitfalls "while read foo\ndo\nmplayer foo.ogv << EOF\nq\nEOF\ndone" prop_checkWhileReadPitfalls12 = verifyNot checkWhileReadPitfalls "while read foo\ndo\nmplayer foo.ogv << EOF\nq\nEOF\ndone"
prop_checkWhileReadPitfalls13 = verify checkWhileReadPitfalls "while read foo; do x=$(ssh host cmd); done" prop_checkWhileReadPitfalls13 = verify checkWhileReadPitfalls "while read foo; do x=$(ssh host cmd); done"
prop_checkWhileReadPitfalls14 = verify checkWhileReadPitfalls "while read foo; do echo $(ssh host cmd) < /dev/null; done" prop_checkWhileReadPitfalls14 = verify checkWhileReadPitfalls "while read foo; do echo $(ssh host cmd) < /dev/null; done"
prop_checkWhileReadPitfalls15 = verify checkWhileReadPitfalls "while read foo; do ssh $foo cmd & done"
checkWhileReadPitfalls params (T_WhileExpression id [command] contents) checkWhileReadPitfalls params (T_WhileExpression id [command] contents)
| isStdinReadCommand command = | isStdinReadCommand command =
@ -2411,6 +2412,7 @@ checkWhileReadPitfalls params (T_WhileExpression id [command] contents)
warnWithFix (getId cmd) 2095 warnWithFix (getId cmd) 2095
("Use " ++ name ++ " " ++ flag ++ " to prevent " ++ name ++ " from swallowing stdin.") ("Use " ++ name ++ " " ++ flag ++ " to prevent " ++ name ++ " from swallowing stdin.")
(fix flag cmd) (fix flag cmd)
checkMuncher (T_Backgrounded _ t) = checkMuncher t
checkMuncher _ = return () checkMuncher _ = return ()
stdinRedirect (T_FdRedirect _ fd op) stdinRedirect (T_FdRedirect _ fd op)