Skip to content

It's not possible to run the ls command inside directories that contain characters "[]" #9232

Closed

Description

@Wint3rmute

Describe the bug

When attempting to list files inside a directory which name contain characters [ and ], nushell fails to display the file list.

How to reproduce

I'm building the main branch at 18th May, but the behaviour is also reproducible on the Arch Linux nushell package (version 0.80.0):

cargo r
mkdir "[test]"
cd "[test]"
ls # this will work as the folder is empty
touch file
ls # this will fail
Error: 
  × No matches found for *
   ╭─[entry #5:1:1]
 1 │ ls
   · ─┬
   ·  ╰── Pattern, file or folder not found
   ╰────
  help: no matches found

Expected behavior

nushell should list the files present in the folder, no matter what characters are present in the folder's name.

Screenshots

image

Configuration

key value
version 0.80.1
branch main
commit_hash e752d8a
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.67.1 (d5a82bbd2 2023-02-07)
rust_channel 1.67.1-x86_64-unknown-linux-gnu
cargo_version cargo 1.67.1 (8ecd4f20a 2023-01-10)
build_time 2023-05-18 22:20:13 +02:00
build_rust_channel debug
features default, zip
installed_plugins

Additional context

No response

Activity

  1. added
    status:needs-triage
    on May 18, 2023
  2. fdncred commented on May 18, 2023

    @fdncred
    Contributor

    I probably broke this when I updated the nu-glob crate a while back. I'm guessing nushell is getting confused because you have a directory named with glob syntax like /some/path/[test] so when you try to do a ls, it's like you're doing ls /some/path/[test]. I'm not sure what the solution should be but I'd hate to remove [] from nu-glob just so people can have directories named with brackets.

  3. bobhy commented on May 20, 2023

    @bobhy
    Contributor

    Candidate, most entertaining bug of the month!
    As a workaround, you can get a list of files in this directory via Nu glob itself!

    ..v| -------------------------/home/bobhy/work/w1/[test] -------------------------
    〉glob *
    ╭───┬────────────────────────────────╮
    │ 0 │ /home/bobhy/work/w1/[test]/foo │
    ╰───┴────────────────────────────────╯
    
  4. fdncred commented on May 20, 2023

    @fdncred
    Contributor

    now that i think about it. this may be why we vendored rust's glob crate way back when. but unfortunately it limits how we can use globs. it would be nice to have a fix for this so we can use brackets in folder paths and still allow our ls to work. maybe there's some way to escape brackets in the code?

  5. baehyunsol commented on Jun 5, 2023

    @baehyunsol
    Contributor

    I found a bug similar to this one, so I'm writting a comment instead of opening a new issue.

    touch "[]" and touch `[]` works, but rm "[]" and rm `[]` don't.

  6. fdncred commented on Jun 5, 2023

    @fdncred
    Contributor

    agreed, brackets cause issues. hopefully #9307 will fix it when it lands.

  7. fdncred commented on Jun 12, 2023

    @fdncred
    Contributor

    If you're interested in a fix for this, could you please test #9416 and let me know how it goes?

  8. added a commit that references this issue on Jun 13, 2023
    8a52085
  9. added this to the v0.82.0 milestone on Jun 14, 2023
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

    status:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions