Skip to main content

shell_argv

Function shell_argv 

Source
pub fn shell_argv(spec: &str, command: &str) -> Vec<String>
Expand description

Builds the argv that runs command through the shell named by spec.

spec is the [general] shell value; a blank or unusable one falls back to DEFAULT_SHELL_ARGV, so this never fails. command is appended as a single final argument — it is the shell’s job to parse it, which is what makes pipelines, quoting and builtins work.

use trail::actions::shell_exec::shell_argv;

assert_eq!(
    shell_argv("pwsh -Command", "./gradlew runClient"),
    vec!["pwsh".to_owned(), "-Command".to_owned(), "./gradlew runClient".to_owned()]
);