Safe Haskell | None |
---|---|
Language | Haskell2010 |
- getHashedShakeVersionP :: [Path r File] -> IO String
- needP :: [Path r File] -> Action ()
- wantP :: [Path r File] -> Rules ()
- ($%>) :: Path r File -> Action () -> Rules ()
- ($&%>) :: [Path r File] -> Action () -> Rules ()
- orderOnlyP :: [Path r File] -> Action ()
- cmd :: CmdArguments args => (:->) args (Action r)
- liftIO :: MonadIO m => forall a. IO a -> m a
- data CmdOption :: *
- = Cwd FilePath
- | Env [(String, String)]
- | AddEnv String String
- | RemEnv String
- | AddPath [String] [String]
- | Stdin String
- | StdinBS ByteString
- | FileStdin FilePath
- | Shell
- | BinaryPipes
- | Traced String
- | Timeout Double
- | WithStdout Bool
- | WithStderr Bool
- | EchoStdout Bool
- | EchoStderr Bool
- | FileStdout FilePath
- | FileStderr FilePath
- | AutoDeps
- module Path
- module Path.IO
Documentation
cmd :: CmdArguments args => (:->) args (Action r) #
Execute a system command. Before running cmd
make sure you need
any files
that are used by the command.
String
arguments are treated as whitespace separated arguments.[String]
arguments are treated as literal arguments.CmdOption
arguments are used as options.
As some examples, here are some calls, and the resulting command string:
cmd_
"git log --pretty=" "oneline" -- git log --pretty= onelinecmd_
"git log --pretty=" ["oneline"] -- git log --pretty= onelinecmd_
"git log" ("--pretty=" ++ "oneline") -- git log --pretty=onelinecmd_
"git log" ("--pretty=" ++ "one line") -- git log --pretty=one linecmd_
"git log" ["--pretty=" ++ "one line"] -- git log "--pretty=one line"
More examples, including return values, see this translation of the examples given for the command
function:
cmd_
"gcc -c myfile.c" -- compile a file, throwing an exception on failureExit
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 outputStdout
out <-cmd
"gcc -MM myfile.c" -- run a command, recording the outputcmd
(Cwd
"generated") "gcc -c" [myfile] ::Action
() -- run a command in a directory
When passing file arguments we use [myfile]
so that if the myfile
variable contains spaces they are properly escaped.
If you use cmd
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 cmd_
.
The cmd
function can also be run in the IO
monad, but then Traced
is ignored and command lines are not echoed.
As an example:
cmd
(Cwd
"generated")Shell
"gcc -c myfile.c" :: IO ()
Options passed to command
or cmd
to control how processes are executed.
Cwd FilePath | Change the current directory in the spawned process. By default uses this processes current directory. |
Env [(String, String)] | Change the environment variables in the spawned process. By default uses this processes environment. |
AddEnv String String | Add an environment variable in the child process. |
RemEnv String | Remove an environment variable from the child process. |
AddPath [String] [String] | Add some items to the prefix and suffix of the |
Stdin String | Given as the |
StdinBS ByteString | Given as the |
FileStdin FilePath | Take the |
Shell | Pass the command to the shell without escaping - any arguments will be joined with spaces. By default arguments are escaped properly. |
BinaryPipes | Treat the |
Traced String | Name to use with |
Timeout Double | Abort the computation after N seconds, will raise a failure exit code. Calls |
WithStdout Bool | Should I include the |
WithStderr Bool | Should I include the |
EchoStdout Bool | Should I echo the |
EchoStderr Bool | Should I echo the |
FileStdout FilePath | Should I put the |
FileStderr FilePath | Should I put the |
AutoDeps | Compute dependencies automatically. |
module Path
module Path.IO