Skip to content

Single quotes should prevent expansion of '~' #4205

Closed

Description

@goj

Describe the bug

Coming from other shells it's a bit surprising that '~' is expanded

How to reproduce

  1. Make a directory named '~' ( ^mkdir '~'), add some content.
  2. See what's there, e.g. ls '~'
    • For the brave: delete it in nushell with rm -r

Expected behavior

Expected

I would expect that specific directory to be listed

Actual

Whole home directory is listed.

This is catastrophic if rm is used instead of ls.

Screenshots

No response

Configuration

No response

Additional context

No response

Activity

  1. sophiajt commented on Dec 13, 2021

    @sophiajt
    Contributor

    In our upcoming engine, I believe that it'll be expanded in both places so your ^mkdir would fail to create a new directory.

    Can you say more about what shells you're coming from that don't use ~ as home? I'm honestly a bit surprised, I thought it was nearly universal (with the exception of maybe something on Windows)

  2. kubouch commented on Dec 13, 2021

    @kubouch
    Contributor

    In Nushell ' and " quotes are treated equal, similar to Python.

    I guess we could add, e.g., --noexpand flag to the filesystem commands to prevent them from expanding the paths. My personal use case for this is when debugging Nushell, sometimes I end up with weird files and directories that are called ~/ for example. You don't want to call rm on that 😀.

  3. added
    A:quoting-expansion
    A:file-system
    on Dec 30, 2022
  4. added a commit that references this issue on Jan 12, 2023
    5419e8a
  5. added this to the v0.75 milestone on Jan 12, 2023
  6. BatmanAoD commented on Oct 26, 2023

    @BatmanAoD
    Contributor

    It looks like #7711 only changes how tilde-expansion is done for external commands; why not make it consistent and always suppress tilde-expansion inside of quotes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:file-systemA:quoting-expansion

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions