use path.try_exist() to fix silent errors (#7069)

This commit is contained in:
Darren Schroeder 2022-11-09 18:54:43 -06:00 committed by GitHub
parent 7b0c0692dc
commit 457f7889df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {
let path = expand_path_with(path, &args.pwd);
Value::Bool {
val: path.exists(),
val: match path.try_exists() {
Ok(exists) => exists,
Err(err) => return Value::Error { error: err.into() },
},
span,
}
}