Merge pull request #1256 from ngzhian/mv-stdin

Do not warn on mv -i (fixes #1251)
This commit is contained in:
Vidar Holen 2018-06-24 11:47:53 -07:00 committed by GitHub
commit f91b5bc270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -2838,6 +2838,7 @@ prop_checkPipeToNowhere5 = verifyNot checkPipeToNowhere "echo foo | xargs du"
prop_checkPipeToNowhere6 = verifyNot checkPipeToNowhere "ls | echo $(cat)" prop_checkPipeToNowhere6 = verifyNot checkPipeToNowhere "ls | echo $(cat)"
prop_checkPipeToNowhere7 = verifyNot checkPipeToNowhere "echo foo | var=$(cat) ls" prop_checkPipeToNowhere7 = verifyNot checkPipeToNowhere "echo foo | var=$(cat) ls"
prop_checkPipeToNowhere8 = verify checkPipeToNowhere "foo | true" prop_checkPipeToNowhere8 = verify checkPipeToNowhere "foo | true"
prop_checkPipeToNowhere9 = verifyNot checkPipeToNowhere "mv -i f . < /dev/stdin"
checkPipeToNowhere :: Parameters -> Token -> WriterT [TokenComment] Identity () checkPipeToNowhere :: Parameters -> Token -> WriterT [TokenComment] Identity ()
checkPipeToNowhere _ t = checkPipeToNowhere _ t =
case t of case t of
@ -2857,6 +2858,7 @@ checkPipeToNowhere _ t =
name <- getCommandBasename cmd name <- getCommandBasename cmd
guard $ name `elem` nonReadingCommands guard $ name `elem` nonReadingCommands
guard . not $ hasAdditionalConsumers cmd guard . not $ hasAdditionalConsumers cmd
guard . not $ name `elem` ["cp", "mv", "rm"] && cmd `hasFlag` "i"
return $ warn (getId cmd) 2217 $ return $ warn (getId cmd) 2217 $
"Redirecting to '" ++ name ++ "', a command that doesn't read stdin. Bad quoting or missing xargs?" "Redirecting to '" ++ name ++ "', a command that doesn't read stdin. Bad quoting or missing xargs?"