From 0a415a7b41f871a514575d0ac2475374f49db70a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 21 Nov 2014 23:30:01 -0400 Subject: show last line if it cannot be parsed as a serialized Result --- src/Propellor/Engine.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Propellor/Engine.hs') 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 -- cgit v1.2.3 From 6eb64d56e3718339b209853b838d04606dcd2dbb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 21 Nov 2014 23:33:39 -0400 Subject: avoid setting title when not at console --- src/Propellor/Engine.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Propellor/Engine.hs') diff --git a/src/Propellor/Engine.hs b/src/Propellor/Engine.hs index 0a51736f..b551ca05 100644 --- a/src/Propellor/Engine.hs +++ b/src/Propellor/Engine.hs @@ -27,7 +27,9 @@ mainProperties :: Host -> IO () mainProperties host = do r <- runPropellor host $ ensureProperties [Property "overall" (ensureProperties $ hostProperties host) mempty] - setTitle "propellor: done" + h <- mkMessageHandle + whenConsole h $ + setTitle "propellor: done" hFlush stdout case r of FailedChange -> exitWith (ExitFailure 1) -- cgit v1.2.3