Function duct::sh
[−]
[src]
pub fn sh<T: ToExecutable>(command: T) -> Expression
Create a command from a string of shell code.
This invokes the operating system's shell to execute the string:
/bin/sh
on Unix-like systems and cmd.exe
on Windows. This can be
very convenient sometimes, especially in small scripts and examples.
You don't need to quote each argument, and all the operators like
|
and >
work as usual.
However, building shell commands at runtime brings up tricky whitespace and
escaping issues, so avoid using sh
and format!
together. Prefer
cmd!
instead in those cases. Also note that shell
commands don't tend to be portable between Unix and Windows.
Example
use duct::sh; let output = sh("echo foo bar baz").read(); assert_eq!("foo bar baz", output.unwrap());