diff --git a/src/std_fns.rs b/src/std_fns.rs index 272768a..f3cf7ee 100644 --- a/src/std_fns.rs +++ b/src/std_fns.rs @@ -829,6 +829,14 @@ pub fn command(stack: &mut Stack) -> OError { } pub fn command_wait(stack: &mut Stack) -> OError { + command_wait_impl(stack, Stdio::inherit) +} + +pub fn command_wait_silent(stack: &mut Stack) -> OError { + command_wait_impl(stack, Stdio::null) +} + +pub fn command_wait_impl(stack: &mut Stack, stdio: fn() -> Stdio) -> OError { let binding = stack.pop(); let Value::Array(ref a) = binding.lock_ro().native else { return stack.err(ErrorKind::InvalidCall("command".to_owned())); @@ -848,9 +856,9 @@ pub fn command_wait(stack: &mut Stack) -> OError { Value::Int( process::Command::new(&args[0]) .args(&args[1..]) - .stdin(Stdio::inherit()) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) + .stdin(stdio()) + .stdout(stdio()) + .stderr(stdio()) .spawn() .map_err(|x| stack.error(ErrorKind::IO(x.to_string())))? .wait() @@ -1150,7 +1158,7 @@ pub fn chdir(stack: &mut Stack) -> OError { pub fn register(r: &mut Stack, o: Arc) { type Fn = fn(&mut Stack) -> OError; - let fns: [(&str, Fn, u32); 69] = [ + let fns: [(&str, Fn, u32); 70] = [ ("pop", pop, 0), ("dup", dup, 2), ("dup2", dup2, 3), @@ -1203,6 +1211,7 @@ pub fn register(r: &mut Stack, o: Arc) { ("readln", readln, 1), ("command", command, 1), ("command-wait", command_wait, 1), + ("command-wait-silent", command_wait_silent, 1), ("str-to-bytes", str_to_bytes, 1), ("bytes-to-str", bytes_to_str, 1), ("acopy", acopy, 1),