mirror of
https://github.com/nushell/nushell.git
synced 2025-07-09 02:48:17 +02:00
# Description Closes #15848. Currently, we expand unquoted strings to absolute paths if they are of type `path` or `directory`. This PR makes this no longer happen. `~`, `.`, and `..+` are still expanded, but a path like `.../foo/bar/..` will only be turned into `../../foo`, rather than a full absolute path. This is mostly so that paths don't get modified before being sent to known external commands (as in the linked issue). But also, it seems unnecessary to make all unquoted paths absolute. After feedback from @132ikl, this PR also makes it so that unquoted paths are expanded at parse time, so that it matches the runtime behavior. Previously, `path` expressions were turned into strings verbatim, while `directory` expressions were treated as not being const. API change: `nu_path::expansions::expand_path` is now exposed as `nu_path::expand_path`. # User-Facing Changes This has the potential to silently break a lot of scripts. For example, if someone has a command that expects an already-expanded absolute path, changes the current working directory, and then passes the path somewhere, they will now need to use `path expand` to expand the path themselves before changing the current working directory. # Tests + Formatting Just added one test to make sure unquoted `path` arguments aren't made absolute. # After Submitting This is a breaking change, so will need to be mentioned in the release notes.
nu-path
This crate takes care of path handling in Nushell, such as canonicalization and component expansion, as well as other path-related utilities.