HSH 2.0.2 → 2.0.3
raw patch · 4 files changed
+16/−15 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- HSH.Command: instance [overlap ok] (ShellCommand a) => ShellCommand (EnvironCommand a)
- HSH.Command: instance [overlap ok] (ShellCommand a) => Show (EnvironCommand a)
- HSH.ShellEquivs: rev :: [String] -> [String]
- HSH.ShellEquivs: revW :: [String] -> [String]
+ HSH.Command: instance [overlap ok] ShellCommand a => ShellCommand (EnvironCommand a)
+ HSH.Command: instance [overlap ok] ShellCommand a => Show (EnvironCommand a)
+ HSH.ShellEquivs: rev, revW :: [String] -> [String]
- HSH.Channel: chanToHandle :: Channel -> Handle -> IO ()
+ HSH.Channel: chanToHandle :: Bool -> Channel -> Handle -> IO ()
- HSH.Channel: toChannel :: (Channelizable a) => a -> Channel
+ HSH.Channel: toChannel :: Channelizable a => a -> Channel
- HSH.Command: class (Show a) => ShellCommand a
+ HSH.Command: class Show a => ShellCommand a
- HSH.Command: fdInvoke :: (ShellCommand a) => a -> Environment -> Channel -> IO (Channel, [InvokeResult])
+ HSH.Command: fdInvoke :: ShellCommand a => a -> Environment -> Channel -> IO (Channel, [InvokeResult])
- HSH.Command: runIO :: (ShellCommand a) => a -> IO ()
+ HSH.Command: runIO :: ShellCommand a => a -> IO ()
- HSH.Command: runSL :: (ShellCommand a) => a -> IO String
+ HSH.Command: runSL :: ShellCommand a => a -> IO String
- HSH.Command: setenv :: (ShellCommand cmd) => [(String, String)] -> cmd -> EnvironCommand cmd
+ HSH.Command: setenv :: ShellCommand cmd => [(String, String)] -> cmd -> EnvironCommand cmd
- HSH.Command: unsetenv :: (ShellCommand cmd) => [String] -> cmd -> EnvironCommand cmd
+ HSH.Command: unsetenv :: ShellCommand cmd => [String] -> cmd -> EnvironCommand cmd
- HSH.ShellEquivs: echo :: (Channelizable a) => a -> Channel -> IO Channel
+ HSH.ShellEquivs: echo :: Channelizable a => a -> Channel -> IO Channel
- HSH.ShellEquivs: setenv :: (ShellCommand cmd) => [(String, String)] -> cmd -> EnvironCommand cmd
+ HSH.ShellEquivs: setenv :: ShellCommand cmd => [(String, String)] -> cmd -> EnvironCommand cmd
- HSH.ShellEquivs: unsetenv :: (ShellCommand cmd) => [String] -> cmd -> EnvironCommand cmd
+ HSH.ShellEquivs: unsetenv :: ShellCommand cmd => [String] -> cmd -> EnvironCommand cmd
Files
- HSH.cabal +1/−1
- HSH/Channel.hs +10/−7
- HSH/Command.hs +3/−3
- HSH/ShellEquivs.hs +2/−4
HSH.cabal view
@@ -1,5 +1,5 @@ Name: HSH-Version: 2.0.2+Version: 2.0.3 License: LGPL Maintainer: John Goerzen <jgoerzen@complete.org> Author: John Goerzen
HSH/Channel.hs view
@@ -52,13 +52,16 @@ let contents = BSL.toChunks r return . BS.concat $ contents -{- | Writes the Channel to the given Handle. -}-chanToHandle :: Channel -> Handle -> IO ()-chanToHandle (ChanString s) h = hPutStr h s-chanToHandle (ChanBSL s) h = BSL.hPut h s-chanToHandle (ChanHandle srchdl) desthdl = forkIO copier >> return ()- where copier = do c <- BSL.hGetContents srchdl- BSL.hPut desthdl c+{- | Writes the Channel to the given Handle. If the first parameter is True,+ do this in a separate thread and close the handle afterwards.+-}+chanToHandle :: Bool -> Channel -> Handle -> IO ()+chanToHandle close c h = if close then forkIO (dumpChanToHandle c h >> hClose h) >> return ()+ else dumpChanToHandle c h+ where dumpChanToHandle (ChanString s) h = hPutStr h s+ dumpChanToHandle (ChanBSL s) h = BSL.hPut h s+ dumpChanToHandle (ChanHandle srchdl) desthdl+ = BSL.hGetContents srchdl >>= BSL.hPut desthdl class Channelizable a where toChannel :: a -> Channel
HSH/Command.hs view
@@ -307,7 +307,7 @@ in do (ih', oh', _, ph) <- createProcess cp let ih = fromJust ih' let oh = fromJust oh'- chanToHandle ichan ih+ chanToHandle True ichan ih return (ChanHandle oh, [(printCmdSpec cspec, waitForProcess ph)]) printCmdSpec :: CmdSpec -> String@@ -379,7 +379,7 @@ instance RunResult (IO (String, ExitCode)) where run cmd = do (ochan, r) <- fdInvoke cmd Nothing (ChanHandle stdin)- chanToHandle ochan stdout+ chanToHandle False ochan stdout processResults r instance RunResult (IO ExitCode) where@@ -424,7 +424,7 @@ instance RunResult (IO (IO (String, ExitCode))) where run cmd = do (ochan, r) <- fdInvoke cmd Nothing (ChanHandle stdin)- chanToHandle ochan stdout+ chanToHandle False ochan stdout return (processResults r) intermediateStringlikeResult :: ShellCommand b =>
HSH/ShellEquivs.hs view
@@ -191,8 +191,7 @@ catTo :: FilePath -> Channel -> IO Channel catTo fp ichan = do ofile <- openFile fp WriteMode- chanToHandle ichan ofile- hClose ofile+ chanToHandle True ichan ofile return (ChanString "") #ifdef __HSH_POSIX__@@ -212,8 +211,7 @@ catToFIFO :: FilePath -> Channel -> IO Channel catToFIFO fp ichan = do h <- fifoOpen fp- chanToHandle ichan h- hClose h+ chanToHandle True ichan h return (ChanString "") fifoOpen :: FilePath -> IO Handle