pub fn make_command(
    cmd: String,
    args: Vec<String>,
    env: HashMap<String, String>,
    cwd: Option<PathBuf>,
) -> Command {
    // refer to https://doc.rust-lang.org/std/process/struct.Command.html#impl
    // notably, a Command will inherit the current env, working dir and stdin/out/err
    let mut command = Command::new(cmd);
    command.args(args);

    // avoid leaking the environment
    command.env_clear();
    command.envs(env);

    // if no path was specified, use the current one
    let cwd = match cwd {
        None => env::current_dir().unwrap(),
        Some(path) => path,
    };
    command.current_dir(cwd);

    // no stdin, but we'll want stdout and stderr afterwards
    command.stdin(Stdio::null());
    command.stdout(Stdio::piped());
    command.stderr(Stdio::piped());

    return command;
}
/// Builds a new command from the given arguments.
Builds a new command from the given arguments.
Builds a new command from the given arguments .
pub fn make_command(
    cmd: String,
    args: Vec<String>,
    env: HashMap<String, String>,
    cwd: Option<PathBuf>,
) -> Command {
    // refer to https://doc.rust-lang.org/std/process/struct.Command.html#impl
    // notably, a Command will inherit the current env, working dir and stdin/out/err
    let mut command = Command::new(cmd);
    command.args(args);
    // avoid leaking the environment
    command.env_clear();
    command.envs(env);
    // if no path was specified, use the current one
    let cwd = match cwd {
        None => env::current_dir().unwrap(),
        Some(path) => path,
    };
    command.current_dir(cwd);
    // no stdin, but we'll want stdout and stderr afterwards
    command.stdin(Stdio::null());
    command.stdout(Stdio::piped());
    command.stderr(Stdio::piped());
    return command;
}
pub fn make_command ( cmd : String , args : Vec < String > , env : HashMap < String , String > , cwd : Option < PathBuf > , ) -> Command { // refer to https://doc.rust-lang.org/std/process/struct.Command.html#impl // notably, a Command will inherit the current env, working dir and stdin/out/err let mut command = Command :: new ( cmd ) ; command . args ( args ) ; // avoid leaking the environment command . env_clear ( ) ; command . envs ( env ) ; // if no path was specified, use the current one let cwd = match cwd { None => env :: current_dir ( ) . unwrap ( ) , Some ( path ) => path , } ; command . current_dir ( cwd ) ; // no stdin, but we'll want stdout and stderr afterwards command . stdin ( Stdio :: null ( ) ) ; command . stdout ( Stdio :: piped ( ) ) ; command . stderr ( Stdio :: piped ( ) ) ; return command ; }
Builds a new command from the given arguments.
Builds a new command from the given arguments .
cmd
String
args
Vec<String>
env
HashMap<String, String>
cwd
Option<PathBuf>
cmd
String
args
Vec<String>
env
HashMap<String, String>
cwd
Option<PathBuf>