32 lines
551 B
Rust
32 lines
551 B
Rust
use std::{
|
|
env,
|
|
process::{ Command, Stdio }
|
|
};
|
|
|
|
fn main() {
|
|
let mut args: Vec<String> = env::args().collect();
|
|
args.remove(0);
|
|
|
|
let target = args.remove(0);
|
|
let command = Command::new(target)
|
|
.args(args)
|
|
.stderr(Stdio::inherit())
|
|
.output();
|
|
if let Ok(output) = command {
|
|
let mut line = String::new();
|
|
for byte in output.stdout {
|
|
match char::from_u32(byte.into()) {
|
|
Some('\n') => {
|
|
println!("{line}");
|
|
line = String::new();
|
|
},
|
|
|
|
Some('\0') |
|
|
None => continue,
|
|
|
|
Some(c) => line.push(c),
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|