Execute a system command. Before running
command make sure you
need any files that are used by the command.
This function takes a list of options (often just
[], see
CmdOption for the available options), the name of the
executable (either a full name, or a program on the
$PATH)
and a list of arguments. The result is often
(), but can be a
tuple containg any of
Stdout,
Stderr and
Exit.
Some examples:
command_ [] "gcc" ["-c","myfile.c"] -- compile a file, throwing an exception on failure
Exit c <- command [] "gcc" ["-c",myfile] -- run a command, recording the exit code
(Exit c, Stderr err) <- command [] "gcc" ["-c","myfile.c"] -- run a command, recording the exit code and error output
Stdout out <- command [] "gcc" ["-MM","myfile.c"] -- run a command, recording the output
command_ [Cwd "generated"] "gcc" ["-c",myfile] -- run a command in a directory
Unless you retrieve the
ExitCode using
Exit, any
ExitFailure will throw an error, including the
Stderr in
the exception message. If you capture the
Stdout or
Stderr, that stream will not be echoed to the console, unless
you use the option
EchoStdout or
EchoStderr.
If you use
command inside a
do block and do not use
the result, you may get a compile-time error about being unable to
deduce
CmdResult. To avoid this error, use
command_.
By default the
stderr stream will be captured for use in
error messages, and also echoed. To only echo pass
WithStderr False, which causes no streams to be
captured by Shake, and certain programs (e.g.
gcc) to detect
they are running in a terminal.