Function duct_sh::sh
[−]
[src]
pub fn sh(command: &'static str) -> Expression
Create a command from a static string of shell code.
This invokes the operating system's shell to execute the string: /bin/sh
on Unix-like systems and cmd.exe
(or %COMSPEC%
) 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.
sh
avoids security issues by accepting only static strings. If you need to
build shell commands at runtime, read the documentation for sh_dangerous
.
Example
use duct_sh::sh; let output = sh("echo foo bar baz").read(); assert_eq!("foo bar baz", output.unwrap());