diff --git a/Cargo.lock b/Cargo.lock index 3847f83f02..2dd2aee9c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -945,6 +945,7 @@ name = "nu-parser" version = "0.1.0" dependencies = [ "miette", + "nu-path", "nu-plugin", "nu-protocol", "thiserror", diff --git a/crates/nu-parser/Cargo.toml b/crates/nu-parser/Cargo.toml index 2eb26d7f1f..9e35e7c712 100644 --- a/crates/nu-parser/Cargo.toml +++ b/crates/nu-parser/Cargo.toml @@ -8,6 +8,7 @@ miette = "3.0.0" thiserror = "1.0.29" nu-protocol = { path = "../nu-protocol"} nu-plugin = { path = "../nu-plugin", optional=true} +nu-path = {path = "../nu-path"} [features] plugin = ["nu-plugin"] diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 03e5e8a9a9..3664e44f8a 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -1437,9 +1437,11 @@ pub fn parse_filepath( let bytes = trim_quotes(bytes); if let Ok(token) = String::from_utf8(bytes.into()) { + let filepath = nu_path::expand_path(token); + let filepath = filepath.to_string_lossy().to_string(); ( Expression { - expr: Expr::Filepath(token), + expr: Expr::Filepath(filepath), span, ty: Type::String, custom_completion: None, @@ -1449,7 +1451,7 @@ pub fn parse_filepath( } else { ( garbage(span), - Some(ParseError::Expected("string".into(), span)), + Some(ParseError::Expected("filepath".into(), span)), ) } } @@ -1649,9 +1651,12 @@ pub fn parse_glob_pattern( let bytes = trim_quotes(bytes); if let Ok(token) = String::from_utf8(bytes.into()) { + let filepath = nu_path::expand_path(token); + let filepath = filepath.to_string_lossy().to_string(); + ( Expression { - expr: Expr::GlobPattern(token), + expr: Expr::GlobPattern(filepath), span, ty: Type::String, custom_completion: None,