Macro cake::cmd [] [src]

macro_rules! cmd {
    ($cmd:expr $(, $arg:expr)*; in $cd:expr $(; where $var:ident = $val:expr)*) => { ... };
    ($cmd:expr $(, $arg:expr)* $(; where $var:ident = $val:expr)*) => { ... };

Execute a command.

Each argument after the first, denoting the executable, represents a respective argument passed to the executable. Optionally, you can specify the working directory by prepending ; in "blah" to the argument list. Any arbitrary number of environment variables can be declared through where VAR = VAL, delimited by ;.

An argument can be of any type implementing AsSlice<T> where T: AsRef<OsStr>, that is, it can take both strings and arrays of strings.


To run a command in the current working directory:

cmd!("ls", "/"); // 'ls /'

If we want to run this in a custom working directory, we can do:

cmd!("ls", "."; in "/");

In case we want to set environment variables, we do:

cmd!("ls", "."; where BLAH = "/"; where BLUH = "!");