summaryrefslogtreecommitdiff
path: root/src/Propellor/Engine.hs
diff options
context:
space:
mode:
authorJoey Hess2014-11-21 23:30:01 -0400
committerJoey Hess2014-11-21 23:30:40 -0400
commit0a415a7b41f871a514575d0ac2475374f49db70a (patch)
treebaedfb0ded5b792ea3c36b8472332ebe12870b94 /src/Propellor/Engine.hs
parent40bfcacf4e4f019153c1679cd3955cb3bb2f047f (diff)
show last line if it cannot be parsed as a serialized Result
Diffstat (limited to 'src/Propellor/Engine.hs')
-rw-r--r--src/Propellor/Engine.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Propellor/Engine.hs b/src/Propellor/Engine.hs
index 969769ce..0a51736f 100644
--- a/src/Propellor/Engine.hs
+++ b/src/Propellor/Engine.hs
@@ -11,7 +11,6 @@ import "mtl" Control.Monad.Reader
import Control.Exception (bracket)
import System.PosixCompat
import System.Posix.IO
-import Data.Maybe
import Propellor.Types
import Propellor.Message
@@ -74,8 +73,14 @@ processChainOutput h = go Nothing
go lastline = do
v <- catchMaybeIO (hGetLine h)
case v of
- Nothing -> pure $ fromMaybe FailedChange $
- readish =<< lastline
+ Nothing -> case lastline of
+ Nothing -> pure FailedChange
+ Just l -> case readish l of
+ Just r -> pure r
+ Nothing -> do
+ putStrLn l
+ hFlush stdout
+ return FailedChange
Just s -> do
maybe noop (\l -> unless (null l) (putStrLn l)) lastline
hFlush stdout