finish conversion to hGetLineUntilExitOrEOF

started in aafae46bcb
This commit is contained in:
Joey Hess 2020-11-18 14:54:02 -04:00
parent 7ec22489da
commit e6d741af79
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 14 additions and 16 deletions

View file

@ -290,12 +290,11 @@ commandMeterExitCode' progressparser oh mmeter meterupdate cmd params mkprocess
meterupdate bytes
feedprogress sendtotalsize' bytes buf' h
handlestderr ph h = unlessM (hIsEOF h) $ do
cancelOnExit ph (hGetLine h) >>= \case
Just l -> do
stderrHandler oh l
handlestderr ph h
Nothing -> return ()
handlestderr ph h = hGetLineUntilExitOrEOF ph h >>= \case
Just l -> do
stderrHandler oh l
handlestderr ph h
Nothing -> return ()
{- Runs a command, that may display one or more progress meters on
- either stdout or stderr, and prevents the meters from being displayed.
@ -323,13 +322,12 @@ demeterCommandEnv oh cmd params environ = do
- beginning of the line when updating a progress display).
-}
avoidProgress :: Bool -> ProcessHandle -> Handle -> (String -> IO ()) -> IO ()
avoidProgress doavoid ph h emitter = unlessM (hIsEOF h) $
cancelOnExit ph (hGetLine h) >>= \case
Just s -> do
unless (doavoid && '\r' `elem` s) $
emitter s
avoidProgress doavoid ph h emitter
Nothing -> return ()
avoidProgress doavoid ph h emitter = hGetLineUntilExitOrEOF ph h >>= \case
Just s -> do
unless (doavoid && '\r' `elem` s) $
emitter s
avoidProgress doavoid ph h emitter
Nothing -> return ()
outputFilter
:: FilePath