mirror of
https://github.com/nushell/nushell.git
synced 2025-04-23 20:58:19 +02:00
use path.try_exist() to fix silent errors (#7069)
This commit is contained in:
parent
7b0c0692dc
commit
457f7889df
@ -105,7 +105,10 @@ If you need to distinguish dirs and files, please use `path type`."#
|
|||||||
fn exists(path: &Path, span: Span, args: &Arguments) -> Value {
|
fn exists(path: &Path, span: Span, args: &Arguments) -> Value {
|
||||||
let path = expand_path_with(path, &args.pwd);
|
let path = expand_path_with(path, &args.pwd);
|
||||||
Value::Bool {
|
Value::Bool {
|
||||||
val: path.exists(),
|
val: match path.try_exists() {
|
||||||
|
Ok(exists) => exists,
|
||||||
|
Err(err) => return Value::Error { error: err.into() },
|
||||||
|
},
|
||||||
span,
|
span,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user