[−][src]Macro stdbench::execute
Executes a $cmd
, checks for results, and returns an error with $errmsg
message.
It is designed to be similar to ?
operator, removing bulky boilerplate from
functions that execute many consecutive commands.
This macro will return error in one of the two cases:
- command execution failed,
- command returned an exit status equivalent to an error.
This macro is intended to be used in simple cases when we do not want to capture the output or learn more about exit status, since the only feedback we get is the error message passed at the call site.
Example
extern crate boolinator; use boolinator::Boolinator; fn f() -> Result<(), Error> { execute!(Command::new("ls"); "couldn't ls"); execute!(Command::new("cat").args(&["some_file"]); "couldn't cat"); Ok(()) } match f() { Ok(()) => println!(), Err(err) => println!("Here's what went wrong"), }