mirror of
https://github.com/nushell/nushell.git
synced 2024-11-07 17:14:23 +01:00
Restore path type
behavior (#13006)
# Description Restores `path type` to return an empty string on error like it did pre 0.94.0.
This commit is contained in:
parent
40772fea15
commit
31f3d2f664
@ -104,10 +104,9 @@ If nothing is found, an empty string will be returned."#
|
||||
|
||||
fn path_type(path: &Path, span: Span, args: &Arguments) -> Value {
|
||||
let path = nu_path::expand_path_with(path, &args.pwd, true);
|
||||
match std::fs::symlink_metadata(path) {
|
||||
Ok(metadata) => Value::string(get_file_type(&metadata), span),
|
||||
Err(err) => Value::error(err.into(), span),
|
||||
}
|
||||
let meta = path.symlink_metadata();
|
||||
let ty = meta.as_ref().map(get_file_type).unwrap_or("");
|
||||
Value::string(ty, span)
|
||||
}
|
||||
|
||||
fn get_file_type(md: &std::fs::Metadata) -> &str {
|
||||
|
Loading…
Reference in New Issue
Block a user