summaryrefslogtreecommitdiff
path: root/Propellor/SimpleSh.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Propellor/SimpleSh.hs')
-rw-r--r--Propellor/SimpleSh.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/Propellor/SimpleSh.hs b/Propellor/SimpleSh.hs
index 971fe502..25a154a9 100644
--- a/Propellor/SimpleSh.hs
+++ b/Propellor/SimpleSh.hs
@@ -22,6 +22,7 @@ data Resp = StdoutLine String | StderrLine String | Done ExitCode
simpleSh :: FilePath -> IO ()
simpleSh namedpipe = do
nukeFile namedpipe
+ createDirectoryIfMissing True (takeDirectory namedpipe)
s <- socket AF_UNIX Stream defaultProtocol
bind s (SockAddrUnix namedpipe)
listen s 2
@@ -71,3 +72,7 @@ simpleShClient namedpipe cmd params handler = do
hPutStrLn h $ show $ Cmd cmd params
resps <- catMaybes . map readish . lines <$> hGetContents h
hClose h `after` handler resps
+
+getStdout :: Resp -> Maybe String
+getStdout (StdoutLine s) = Just s
+getStdout _ = Nothing