Skip to content

Don't expand ndots if prefixed with ./#14755

Merged
ysthakur merged 2 commits intonushell:mainfrom
132ikl:golang-ndots
Jan 5, 2025
Merged

Don't expand ndots if prefixed with ./#14755
ysthakur merged 2 commits intonushell:mainfrom
132ikl:golang-ndots

Conversation

@132ikl
Copy link
Copy Markdown
Member

@132ikl 132ikl commented Jan 5, 2025

Description

Prevents ndots from being expanded if they are prefixed with ./, as the agreed resolution to #13303. Only applies to externals, mirroring the fix from #13218.

I did attempt to apply the fix for internal commands as well, but it seems like the path is expanded too aggressively and I haven't investigated it further yet. ./... gets normalized into <pwd>/./..., which gets normalized into <pwd>/... before being handed to expand_ndots, and at that point it just looks like a normal n-dots so we can't tell we shouldn't expand.

(Fixes #13303)

User-Facing Changes

  • N-dots are no longer expanded to external command calls when prefixed with ./.

Tests + Formatting

Added tests to prevent regression.

  • 🟢 toolkit fmt
  • 🟢 toolkit clippy
  • 🟢 toolkit test
  • 🟢 toolkit test stdlib

After Submitting

N/A


/// Expand tilde ("~") into a home directory if it is the first path component
pub fn expand_tilde(path: impl AsRef<Path>) -> PathBuf {
// TODO: Extend this to work with "~user" style of home paths
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this working now? (I have no idea what ~user style is)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. Strangely enough, ls ~ and ls ~fdncred return the same thing on my mac.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my bad, I meant to comment on this in the PR description. yes, this is an old comment. this was implemented in #5251

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what ~user style is

~user is expanded to the home directory of user.

Strangely enough, ls ~ and ls ~fdncred return the same thing on my mac.

That's how it works. Effectively, ~ is a shortcut to ~($env.USER) where $env.USER is the current user.

Copy link
Copy Markdown
Member

@ysthakur ysthakur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ysthakur ysthakur merged commit b60f91f into nushell:main Jan 5, 2025
@github-actions github-actions bot added this to the v0.102.0 milestone Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Golang ./... wildcard path syntax regression

4 participants