mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 15:11:52 +02:00
Fix ls relative path & command argument path expansion (#757)
* Switch to short-names when the path is a relative_path (a dir) and exit with an error if the path does not exist * Remove debugging print line * Show relative filenames... It does not work yet for ls ../ * Try something else to fix relative paths... it works, but the ../ code part is not very pretty * Add canonicalize check and remove code clones * Fix the canonicalize_with issue pointed out by kubouch. Not sure the prefix_str is what kubouch suggested * Fix the canonicalize_with issue pointed out by kubouch. Not sure the prefix_str is what kubouch suggested * Add single-dot expansion to nu-path * Move value path expansion from parser to eval Fixes #745 * Remove single dot expansion from parser It is not necessary since it will get expanded anyway in the eval. * Fix ls to display globs with relative paths * Use pathdiff crate to get relative paths for ls Co-authored-by: Stefan Stanciulescu <contact@stefanstanciulescu.com>
This commit is contained in:
@ -1616,20 +1616,15 @@ pub fn parse_filepath(
|
||||
working_set: &mut StateWorkingSet,
|
||||
span: Span,
|
||||
) -> (Expression, Option<ParseError>) {
|
||||
let cwd = working_set.get_cwd();
|
||||
|
||||
let bytes = working_set.get_span_contents(span);
|
||||
let bytes = trim_quotes(bytes);
|
||||
trace!("parsing: filepath");
|
||||
|
||||
if let Ok(token) = String::from_utf8(bytes.into()) {
|
||||
let filepath = nu_path::expand_path_with(token, cwd);
|
||||
let filepath = filepath.to_string_lossy().to_string();
|
||||
trace!("-- found {}", filepath);
|
||||
|
||||
trace!("-- found {}", token);
|
||||
(
|
||||
Expression {
|
||||
expr: Expr::Filepath(filepath),
|
||||
expr: Expr::Filepath(token),
|
||||
span,
|
||||
ty: Type::String,
|
||||
custom_completion: None,
|
||||
@ -1849,15 +1844,10 @@ pub fn parse_glob_pattern(
|
||||
let bytes = trim_quotes(bytes);
|
||||
|
||||
if let Ok(token) = String::from_utf8(bytes.into()) {
|
||||
let cwd = working_set.get_cwd();
|
||||
trace!("-- found {}", token);
|
||||
|
||||
let filepath = nu_path::expand_path_with(token, cwd);
|
||||
let filepath = filepath.to_string_lossy().to_string();
|
||||
|
||||
(
|
||||
Expression {
|
||||
expr: Expr::GlobPattern(filepath),
|
||||
expr: Expr::GlobPattern(token),
|
||||
span,
|
||||
ty: Type::String,
|
||||
custom_completion: None,
|
||||
|
Reference in New Issue
Block a user