mirror of
https://github.com/sharkdp/fd.git
synced 2024-09-28 21:11:30 +02:00
Just trying some things out, initial functionality
This commit is contained in:
parent
1795e0e9dd
commit
0f0fa76c81
@ -9,10 +9,24 @@ use crate::exit_codes::ExitCode;
|
|||||||
/// Executes a command.
|
/// Executes a command.
|
||||||
pub fn execute_command(mut cmd: Command, out_perm: &Mutex<()>) -> ExitCode {
|
pub fn execute_command(mut cmd: Command, out_perm: &Mutex<()>) -> ExitCode {
|
||||||
// Spawn the supplied command.
|
// Spawn the supplied command.
|
||||||
let output = cmd.output();
|
/* let output = cmd.output(); */
|
||||||
|
// This sort of works:
|
||||||
|
let child = cmd.spawn().expect("failed to wait on child");
|
||||||
|
let output = child
|
||||||
|
.wait_with_output()
|
||||||
|
.expect("failed to wait on child");
|
||||||
|
ExitCode::Success
|
||||||
|
/* let child_handle = cmd.spawn();
|
||||||
|
match child_handle {
|
||||||
|
Ok(output) => {
|
||||||
|
let exit_code = output.wait();
|
||||||
|
}
|
||||||
|
Err() => {
|
||||||
|
|
||||||
|
}
|
||||||
|
} */
|
||||||
// Then wait for the command to exit, if it was spawned.
|
// Then wait for the command to exit, if it was spawned.
|
||||||
match output {
|
/* match output {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
// While this lock is active, this thread will be the only thread allowed
|
// While this lock is active, this thread will be the only thread allowed
|
||||||
// to write its outputs.
|
// to write its outputs.
|
||||||
@ -21,8 +35,8 @@ pub fn execute_command(mut cmd: Command, out_perm: &Mutex<()>) -> ExitCode {
|
|||||||
let stdout = io::stdout();
|
let stdout = io::stdout();
|
||||||
let stderr = io::stderr();
|
let stderr = io::stderr();
|
||||||
|
|
||||||
let _ = stdout.lock().write_all(&output.stdout);
|
//let _ = stdout.lock().write_all(&output.stdout);
|
||||||
let _ = stderr.lock().write_all(&output.stderr);
|
//let _ = stderr.lock().write_all(&output.stderr);
|
||||||
|
|
||||||
if output.status.code() == Some(0) {
|
if output.status.code() == Some(0) {
|
||||||
ExitCode::Success
|
ExitCode::Success
|
||||||
@ -38,5 +52,5 @@ pub fn execute_command(mut cmd: Command, out_perm: &Mutex<()>) -> ExitCode {
|
|||||||
print_error(format!("Problem while executing command: {}", why));
|
print_error(format!("Problem while executing command: {}", why));
|
||||||
ExitCode::GeneralError
|
ExitCode::GeneralError
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user