pub struct Command { /* private fields */ }Expand description
Structured description of an external command to run.
Command stores a program and argument vector instead of parsing a
shell-like command line. This avoids quoting ambiguity and accidental shell
injection. Use Self::shell only when shell parsing, redirection,
expansion, or pipes are intentionally required.
§Author
Haixing Hu
Implementations§
Source§impl Command
impl Command
Sourcepub fn shell(command_line: &str) -> Self
pub fn shell(command_line: &str) -> Self
Creates a command executed through the platform shell.
On Unix-like platforms this creates sh -c <command_line>. On Windows
this creates cmd /C <command_line>. Prefer Self::new with explicit
arguments when shell parsing is not required.
§Parameters
command_line- Shell command line to execute.
§Returns
A command that invokes the platform shell.
Sourcepub fn working_directory<P>(self, working_directory: P) -> Self
pub fn working_directory<P>(self, working_directory: P) -> Self
Sourcepub fn working_directory_override(&self) -> Option<&Path>
pub fn working_directory_override(&self) -> Option<&Path>
Returns the per-command working directory override.
§Returns
Some(path) when the command has a working directory override, or
None when the runner default should be used.
Sourcepub fn environment(&self) -> &[(OsString, OsString)]
pub fn environment(&self) -> &[(OsString, OsString)]
Returns environment variable overrides.
§Returns
Borrowed environment variable entries in insertion order.