mirror of
https://github.com/nushell/nushell
synced 2024-12-27 13:33:16 +00:00
Fix panic when opening symlink which points to an inaccessible directory (#6034)
* Fix panic when opening symlink which points to an inaccessible directory Fixes #6027 Signed-off-by: nibon7 <nibon7@163.com> * tweak words Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
parent
61e027b227
commit
47c1f475bf
1 changed files with 8 additions and 8 deletions
|
@ -88,14 +88,14 @@ impl Command for Open {
|
|||
|
||||
if permission_denied(&path) {
|
||||
#[cfg(unix)]
|
||||
let error_msg = format!(
|
||||
"The permissions of {:o} do not allow access for this user",
|
||||
path.metadata()
|
||||
.expect("this shouldn't be called since we already know there is a dir")
|
||||
.permissions()
|
||||
.mode()
|
||||
& 0o0777
|
||||
);
|
||||
let error_msg = match path.metadata() {
|
||||
Ok(md) => format!(
|
||||
"The permissions of {:o} does not allow access for this user",
|
||||
md.permissions().mode() & 0o0777
|
||||
),
|
||||
Err(e) => e.to_string(),
|
||||
};
|
||||
|
||||
#[cfg(not(unix))]
|
||||
let error_msg = String::from("Permission denied");
|
||||
Err(ShellError::GenericError(
|
||||
|
|
Loading…
Reference in a new issue