| License | BSD3 |
|---|---|
| Maintainer | tbidne@gmail.com |
| Safe Haskell | None |
| Language | Haskell2010 |
Common.IO
Description
Exports common IO functions.
Synopsis
- sh :: Text -> Maybe FilePath -> IO Text
- sh_ :: Text -> Maybe FilePath -> IO ()
- trySh :: Text -> Maybe FilePath -> IO (Either SomeException Text)
- tryShAndReturnStdErr :: Text -> Maybe FilePath -> IO (Either Text Text)
- tryShExitCode :: Text -> Maybe FilePath -> IO (Either Text Text)
- tryTimeSh :: Text -> Maybe FilePath -> IO (Either (RNonNegative Int, Text) (RNonNegative Int, Text))
Documentation
tryShAndReturnStdErr :: Text -> Maybe FilePath -> IO (Either Text Text) Source #
This is an odd function; it returns stderr on both success and failure.
Why is this useful? There are some shell commands that set the return code
to 0 (success) but also return information we care about as stderr.
Performing git push on a branch that is already up-to-date is an example
that "succeeds", but the output we care about ("Everything up-to-date") is
inexplicably sent to stderr instead of stdout. This function is meant for
these situations, where we still want the usual trySh semantics, but want
to paradoxically return stderr on success.
tryTimeSh :: Text -> Maybe FilePath -> IO (Either (RNonNegative Int, Text) (RNonNegative Int, Text)) Source #
Version of tryShExitCode that also returns (t, stdout/stderr), where
t is the time the command took in seconds.