From f449baf8deb459c0e6e1f7fa374453f52e6e9557 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Mon, 28 Dec 2020 14:52:28 -0600 Subject: [PATCH] Change ls to output path (#2829) * make name a path vs string * add support for comparing path to string --- crates/nu-cli/src/shell/filesystem_shell.rs | 2 +- crates/nu-data/src/base.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/nu-cli/src/shell/filesystem_shell.rs b/crates/nu-cli/src/shell/filesystem_shell.rs index e9036ff024..80c299dc39 100644 --- a/crates/nu-cli/src/shell/filesystem_shell.rs +++ b/crates/nu-cli/src/shell/filesystem_shell.rs @@ -979,7 +979,7 @@ pub(crate) fn dir_entry_dict( ) })?; - dict.insert_untagged("name", UntaggedValue::string(name)); + dict.insert_untagged("name", UntaggedValue::path(name)); if let Some(md) = metadata { dict.insert_untagged("type", get_file_type(md)); diff --git a/crates/nu-data/src/base.rs b/crates/nu-data/src/base.rs index d2e5519892..67095305ae 100644 --- a/crates/nu-data/src/base.rs +++ b/crates/nu-data/src/base.rs @@ -152,6 +152,12 @@ pub fn coerce_compare_primitive( (Date(left), Date(right)) => CompareValues::Date(*left, *right), (Date(left), Duration(right)) => CompareValues::DateDuration(*left, right.clone()), (Boolean(left), Boolean(right)) => CompareValues::Booleans(*left, *right), + (Path(left), String(right)) => { + CompareValues::String(left.as_path().display().to_string(), right.clone()) + } + (String(left), Path(right)) => { + CompareValues::String(left.clone(), right.as_path().display().to_string()) + } _ => return Err((left.type_name(), right.type_name())), }) }