cli-utils-4.1.0
LicenseBSD3
Maintainertbidne@gmail.com
Safe HaskellNone
LanguageHaskell2010

Common.IO

Description

Exports common IO functions.

Synopsis

Documentation

sh :: Text -> Maybe FilePath -> IO Text Source #

Returns the result of running a shell command given by Text on FilePath.

sh_ :: Text -> Maybe FilePath -> IO () Source #

Version of sh that ignores the return value.

trySh :: Text -> Maybe FilePath -> IO (Either SomeException Text) Source #

Attempts to return the result of running a shell command given by Text on FilePath.

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.

tryShExitCode :: Text -> Maybe FilePath -> IO (Either Text Text) Source #

Returns Left stderr if there is a failure, Right stdout otherwise.

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.