Compare commits

...

2 commits

Author SHA1 Message Date
8c2b6724da
dont inherit stdio in command function 2024-11-22 13:07:34 +01:00
e55a619862
return PID from command function 2024-11-22 13:06:16 +01:00

View file

@ -812,13 +812,19 @@ pub fn command(stack: &mut Stack) -> OError {
if args.is_empty() { if args.is_empty() {
return stack.err(ErrorKind::InvalidCall("command".to_owned())); return stack.err(ErrorKind::InvalidCall("command".to_owned()));
} }
stack.push(
Value::Long(
process::Command::new(&args[0]) process::Command::new(&args[0])
.args(&args[1..]) .args(&args[1..])
.stdin(Stdio::inherit()) .stdin(Stdio::null())
.stdout(Stdio::inherit()) .stdout(Stdio::null())
.stderr(Stdio::inherit()) .stderr(Stdio::null())
.spawn() .spawn()
.map_err(|x| stack.error(ErrorKind::IO(x.to_string())))?; .map_err(|x| stack.error(ErrorKind::IO(x.to_string())))?
.id() as i64,
)
.spl(),
);
Ok(()) Ok(())
} }
@ -1195,7 +1201,7 @@ pub fn register(r: &mut Stack, o: Arc<Frame>) {
("alit-end", alit_end, 1), ("alit-end", alit_end, 1),
("import", import, 0), ("import", import, 0),
("readln", readln, 1), ("readln", readln, 1),
("command", command, 0), ("command", command, 1),
("command-wait", command_wait, 1), ("command-wait", command_wait, 1),
("str-to-bytes", str_to_bytes, 1), ("str-to-bytes", str_to_bytes, 1),
("bytes-to-str", bytes_to_str, 1), ("bytes-to-str", bytes_to_str, 1),