mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
env: handle the error properly
instead of:
env: unknown error: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
This commit is contained in:
Vendored
+13
-10
@@ -539,16 +539,19 @@ impl EnvAppData {
|
||||
}
|
||||
return Err(exit.code().unwrap().into());
|
||||
}
|
||||
Err(ref err)
|
||||
if (err.kind() == io::ErrorKind::NotFound)
|
||||
|| (err.kind() == io::ErrorKind::InvalidInput) =>
|
||||
{
|
||||
return Err(self.make_error_no_such_file_or_dir(prog.deref()));
|
||||
}
|
||||
Err(e) => {
|
||||
uucore::show_error!("unknown error: {:?}", e);
|
||||
return Err(126.into());
|
||||
}
|
||||
Err(ref err) => match err.kind() {
|
||||
io::ErrorKind::NotFound | io::ErrorKind::InvalidInput => {
|
||||
return Err(self.make_error_no_such_file_or_dir(prog.deref()));
|
||||
}
|
||||
io::ErrorKind::PermissionDenied => {
|
||||
uucore::show_error!("{}: Permission denied", prog.quote());
|
||||
return Err(126.into());
|
||||
}
|
||||
_ => {
|
||||
uucore::show_error!("unknown error: {:?}", err);
|
||||
return Err(126.into());
|
||||
}
|
||||
},
|
||||
Ok(_) => (),
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -80,6 +80,15 @@ fn test_env_version() {
|
||||
.stdout_contains(util_name!());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_env_permissions() {
|
||||
new_ucmd!()
|
||||
.arg(".")
|
||||
.fails()
|
||||
.code_is(126)
|
||||
.stderr_is("env: '.': Permission denied\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_echo() {
|
||||
#[cfg(target_os = "windows")]
|
||||
|
||||
Reference in New Issue
Block a user