summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorJoey Hess2017-07-05 13:23:33 -0400
committerJoey Hess2017-07-05 13:23:33 -0400
commit4eb2a663e4d4ff00d121c5f595f2eb7248b98199 (patch)
treec451826187dd435de8e8eef3125d7b5e087e6f20 /src/Propellor
parent88c02486abcf45067483bd6a138b046397491889 (diff)
Revert "speed up chain output displaying"
This reverts commit c59ce983999ddbfe6cb8b27e4f376b5c37d7f853. That was wrong because only the *last* line of chain output is a Result. It could be that a previous line is able to be read as a Result, and the commit would make processing bail out at that point.
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Message.hs25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/Propellor/Message.hs b/src/Propellor/Message.hs
index 1551eb7d..c56f0c5a 100644
--- a/src/Propellor/Message.hs
+++ b/src/Propellor/Message.hs
@@ -27,12 +27,10 @@ import System.IO.Unsafe (unsafePerformIO)
import Control.Concurrent
import System.Console.Concurrent
import Control.Applicative
-import Control.Monad
import Prelude
import Propellor.Types
import Propellor.Types.Exception
-import Propellor.Debug
import Utility.PartialPrelude
import Utility.Monad
import Utility.Exception
@@ -149,20 +147,21 @@ colorLine intensity color msg = concat <$> sequence
processChainOutput :: Handle -> IO Result
processChainOutput h = go Nothing
where
- go rval = do
+ go lastline = do
v <- catchMaybeIO (hGetLine h)
case v of
- Nothing -> case rval of
- Nothing -> return FailedChange
- Just r -> return r
- Just s -> do
- case readish s of
+ Nothing -> case lastline of
+ Nothing -> do
+ return FailedChange
+ Just l -> case readish l of
+ Just r -> pure r
Nothing -> do
- unless (null s) $ do
- debug ["chain process output", show v]
- outputConcurrent (s ++ "\n")
- go rval
- Just rval' -> go rval'
+ outputConcurrent (l ++ "\n")
+ return FailedChange
+ Just s -> do
+ outputConcurrent $
+ maybe "" (\l -> if null l then "" else l ++ "\n") lastline
+ go (Just s)
-- | Called when all messages about properties have been printed.
messagesDone :: IO ()