Conveniently run shell commands in Haskell (extracted from the Shake build system)
Haskell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/System
.gitignore
README.md
command.cabal

README.md

command

This is a standalone version of the powerful and intuitive command line functions present in the Shake build system (so that they work in plain IO).

They are intended as an easy-to-remember, easy-to-use alternative to the System.Process functions.

Examples

The function with most convenience is cmd.

cmd "gcc -c myfile.c"     -- compile a file, throwing an exception on failure

cmd understands what you want to do using type inference.

Stdout out <- cmd "gcc -MM myfile.c"                   -- run a command, recording the output
Exit c <- cmd "gcc -c" [myfile]                        -- run a command, recording the exit code
(Exit c, Stderr err) <- cmd "gcc -c myfile.c"          -- run a command, recording the exit code and error output
cmd (Cwd "generated") "gcc -c" [myfile] :: Action ()   -- run a command in a directory

Credit

All credit goes to the Shake author!

I hope he'll take it over as a standalone project.