mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 17:35:16 +01:00
Use full names in command.rs
This commit is contained in:
parent
9f39f1d75b
commit
5a12a5e421
1 changed files with 11 additions and 11 deletions
|
@ -10,15 +10,15 @@ struct Outputs {
|
||||||
stdout: Vec<u8>,
|
stdout: Vec<u8>,
|
||||||
stderr: Vec<u8>,
|
stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
struct OutputBuf<'a> {
|
struct OutputBuffer<'a> {
|
||||||
out_perm: &'a Mutex<()>,
|
output_permission: &'a Mutex<()>,
|
||||||
outputs: Vec<Outputs>,
|
outputs: Vec<Outputs>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> OutputBuf<'a> {
|
impl<'a> OutputBuffer<'a> {
|
||||||
fn new(out_perm: &'a Mutex<()>) -> Self {
|
fn new(output_permission: &'a Mutex<()>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
out_perm,
|
output_permission,
|
||||||
outputs: Vec::new(),
|
outputs: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ impl<'a> OutputBuf<'a> {
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
let _lock = self.out_perm.lock().unwrap();
|
let _lock = self.output_permission.lock().unwrap();
|
||||||
|
|
||||||
let stdout = io::stdout();
|
let stdout = io::stdout();
|
||||||
let stderr = io::stderr();
|
let stderr = io::stderr();
|
||||||
|
@ -55,7 +55,7 @@ pub fn execute_commands<I: Iterator<Item = Command>>(
|
||||||
out_perm: &Mutex<()>,
|
out_perm: &Mutex<()>,
|
||||||
enable_output_buffering: bool,
|
enable_output_buffering: bool,
|
||||||
) -> ExitCode {
|
) -> ExitCode {
|
||||||
let mut out_buf = OutputBuf::new(out_perm);
|
let mut output_buffer = OutputBuffer::new(out_perm);
|
||||||
for mut cmd in cmds {
|
for mut cmd in cmds {
|
||||||
// Spawn the supplied command.
|
// Spawn the supplied command.
|
||||||
let output = if enable_output_buffering {
|
let output = if enable_output_buffering {
|
||||||
|
@ -70,20 +70,20 @@ pub fn execute_commands<I: Iterator<Item = Command>>(
|
||||||
match output {
|
match output {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
if enable_output_buffering {
|
if enable_output_buffering {
|
||||||
out_buf.push(output.stdout, output.stderr);
|
output_buffer.push(output.stdout, output.stderr);
|
||||||
}
|
}
|
||||||
if output.status.code() != Some(0) {
|
if output.status.code() != Some(0) {
|
||||||
out_buf.write();
|
output_buffer.write();
|
||||||
return ExitCode::GeneralError;
|
return ExitCode::GeneralError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(why) => {
|
Err(why) => {
|
||||||
out_buf.write();
|
output_buffer.write();
|
||||||
return handle_cmd_error(&cmd, why);
|
return handle_cmd_error(&cmd, why);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out_buf.write();
|
output_buffer.write();
|
||||||
ExitCode::Success
|
ExitCode::Success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue