mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
stdbuf: better handling when non existing files
Should fix tests/misc/stdbuf
This commit is contained in:
parent
79645d45ce
commit
04d4c9e1ef
2 changed files with 30 additions and 12 deletions
|
@ -159,18 +159,26 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let mut process = match command.spawn() {
|
let mut process = match command.spawn() {
|
||||||
Ok(process) => process,
|
Ok(process) => process,
|
||||||
Err(e) if e.kind() == std::io::ErrorKind::PermissionDenied => {
|
Err(e) => match e.kind() {
|
||||||
return Err(USimpleError::new(
|
std::io::ErrorKind::PermissionDenied => {
|
||||||
126,
|
return Err(USimpleError::new(
|
||||||
"failed to execute process: Permission denied",
|
126,
|
||||||
));
|
"failed to execute process: Permission denied",
|
||||||
}
|
));
|
||||||
Err(e) => {
|
}
|
||||||
return Err(USimpleError::new(
|
std::io::ErrorKind::NotFound => {
|
||||||
1,
|
return Err(USimpleError::new(
|
||||||
format!("failed to execute process: {}", e),
|
127,
|
||||||
));
|
"failed to execute process: No such file or directory",
|
||||||
}
|
));
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
return Err(USimpleError::new(
|
||||||
|
1,
|
||||||
|
format!("failed to execute process: {}", e),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let status = process.wait().map_err_context(String::new)?;
|
let status = process.wait().map_err_context(String::new)?;
|
||||||
|
|
|
@ -20,6 +20,16 @@ fn test_permission() {
|
||||||
.stderr_contains("Permission denied");
|
.stderr_contains("Permission denied");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_no_such() {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("-o1")
|
||||||
|
.arg("no_such")
|
||||||
|
.fails()
|
||||||
|
.code_is(127)
|
||||||
|
.stderr_contains("No such file or directory");
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(all(not(target_os = "windows"), not(target_os = "openbsd")))]
|
#[cfg(all(not(target_os = "windows"), not(target_os = "openbsd")))]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stdbuf_unbuffered_stdout() {
|
fn test_stdbuf_unbuffered_stdout() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue