Repository navigation
Closed
Labels
deprecated:duplicate(deprecated: use GitHub's "close as duplicate" feature) This issue is a duplicate of another issue
Description
Describe the bug
File names with square brackets are treated as globs and cannot be literally referenced as far as I can tell.
touch '[hello].txt'
ls '[hello].txt'
Error: × No matches found for [hello].txt
╭─[entry #14:1:1]
1 │ ls '[hello].txt'
· ──────┬──────
· ╰── Pattern, file or folder not found
╰────
help: no matches found
How to reproduce
touch '[hello].txt'ls '[hello].txt'
Expected behavior
I expect to be able to ls a file with square brackets with escapes (e.g. \[ \]) or otherwise and that the completion uses the "right" string to reference the file.
Screenshots
No response
Configuration
| key | value |
| ------------------ | ----------------------------------------------------------------- |
| version | 0.84.0 |
| branch | |
| commit_hash | |
| build_os | macos-aarch64 |
| build_target | aarch64-apple-darwin |
| rust_version | rustc 1.71.1 (eb26296b5 2023-08-03) (built from a source tarball) |
| cargo_version | cargo 1.71.1 |
| build_time | 1980-01-01 00:00:00 +00:00 |
| build_rust_channel | release |
| allocator | standard |
| features | default, sqlite, trash, which, zip |
| installed_plugins | |
Additional context
Other ways to get the same error:
ls $'[hello].txt'
ls '\[hello\].txt'
ls \[hello\].txt
There is a slightly different error when not in quotes:
ls [hello].txt
Error: nu::parser::parse_mismatch
× Parse mismatch during operation.
╭─[entry #42:1:1]
1 │ ls [hello].txt
· ─────┬─────
· ╰── expected non-[] value
╰────
Metadata
Metadata
Assignees
Labels
deprecated:duplicate(deprecated: use GitHub's "close as duplicate" feature) This issue is a duplicate of another issue
Activity
takac commentedon Sep 5, 2023
Some additional oddities
Does not produce an error
Then a error opening files with square brackets in this way
fdncred commentedon Sep 5, 2023
Here's what we can do on the latest main branch. Not sure it works on the version you're using.
[and]are known glob patterns, so I think they currently have to be escaped this way.takac commentedon Sep 5, 2023
Thanks! That does work on
main. The completer/menu probably needs updating to use the right escape sequence. And the escape sequence to be documented somewhere.There are so other oddities with
openand the json which need exploring. Should I open a separate bugs for those in the comment above?fdncred commentedon Sep 5, 2023
I'd like a more holistic solution myself. This escaping is just ugly and no one will really know to do it. Not sure what to do here exactly myself.
amtoine commentedon Sep 6, 2023
this looks possibly a duplicate of #9310, can you have a look @takac? 😋
takac commentedon Sep 8, 2023
Yes they are related, or even duplicate. Seems like a more general issue than just
lsor any other command as it's about globs.