fn spawn_command(cmd: &Cmd) -> bool {
    let flag = cmd.args.last();
    // If it doesn't need to wait
    if flag != None && flag.unwrap() == "&" {
        match Command::new(cmd.command.clone())
            .args(cmd.args.clone())
            .stdout(Stdio::piped())
            .spawn() {
                Ok(_) => {
                    true
                },
                Err(_) => {
                    eprintln!("Unknown command: {}", cmd.command);
                    false
                }
            }
    }
    // If it needs to wait
    else {
        match Command::new(cmd.command.clone())
            .args(cmd.args.clone())
            .spawn() {
                Ok(mut child) => {
                    child.wait().unwrap();
                    true
                },
                Err(_) => {
                    eprintln!("Unknown command: {}", cmd.command);
                    false
                }
            }
        
    }
}
// A function use to spawn a process for an executable
A function use to spawn a process for an executable
A function use to spawn a process for an executable
fn spawn_command(cmd: &Cmd) -> bool {
    let flag = cmd.args.last();
    // If it doesn't need to wait
    if flag != None && flag.unwrap() == "&" {
        match Command::new(cmd.command.clone())
            .args(cmd.args.clone())
            .stdout(Stdio::piped())
            .spawn() {
                Ok(_) => {
                    true
                },
                Err(_) => {
                    eprintln!("Unknown command: {}", cmd.command);
                    false
                }
            }
    }
    // If it needs to wait
    else {
        match Command::new(cmd.command.clone())
            .args(cmd.args.clone())
            .spawn() {
                Ok(mut child) => {
                    child.wait().unwrap();
                    true
                },
                Err(_) => {
                    eprintln!("Unknown command: {}", cmd.command);
                    false
                }
            }
    }
}
fn spawn_command ( cmd : & Cmd ) -> bool { let flag = cmd . args . last ( ) ; // If it doesn't need to wait if flag != None && flag . unwrap ( ) == " " { match Command :: new ( cmd . command . clone ( ) ) . args ( cmd . args . clone ( ) ) . stdout ( Stdio :: piped ( ) ) . spawn ( ) { Ok ( _ ) => { true } , Err ( _ ) => { eprintln ! ( " " cmd command ) ; false } } } // If it needs to wait else { match Command :: new ( cmd . command . clone ( ) ) . args ( cmd . args . clone ( ) ) . spawn ( ) { Ok ( mut child ) => { child . wait ( ) . unwrap ( ) ; true } , Err ( _ ) => { eprintln ! ( " " cmd command ) ; false } } } }
A function use to spawn a process for an executable
A function use to spawn a process for an executable
cmd
&Cmd
cmd
&Cmd