Repository navigation
Closed
Labels
A:file-systemRelated to commands and core nushell behavior around the file systemA:globBehavior around file-system globbing with regular commands or `glob`. See also A:quoting/expansioncategory:bugSomething isn't working
Milestone
Description
Describe the bug
nushell is able to find the file test[].txt:
nu❯ ls
╭───┬────────────┬──────┬──────┬───────────────╮
│ # │ name │ type │ size │ modified │
├───┼────────────┼──────┼──────┼───────────────┤
│ 0 │ test.txt │ file │ 13 B │ 9 minutes ago │
│ 1 │ test[].txt │ file │ 13 B │ 9 minutes ago │
╰───┴────────────┴──────┴──────┴───────────────╯
nu❯ ls | get name | path exists
╭───┬──────╮
│ 0 │ true │
│ 1 │ true │
╰───┴──────╯
but is not able to open it:
nu❯ open test[].txt
Error:
× Error extracting glob pattern
╭─[entry #21:1:1]
1 │ open test[].txt
· ──┬─
· ╰── Pattern syntax error near position 40: invalid range pattern
╰────
if I try to open the file without [ ] it works just fine:
nu❯ open test.txt
lorem ipsum
using any kind of quotes does not help (", ', `)
nu✗ open `test[].txt`
Error:
× Error extracting glob pattern
╭─[entry #27:1:1]
1 │ open `test[].txt`
· ──┬─
· ╰── Pattern syntax error near position 40: invalid range pattern
╰────
the cp, and rm commands exhibits the same error
nu✗ rm 'test[].txt'
Error:
× Pattern syntax error near position 40: invalid range pattern
╭─[entry #31:1:1]
1 │ rm 'test[].txt'
· ──────┬─────
· ╰── Pattern syntax error near position 40: invalid range pattern
╰────
but the mv command has a different error message:
nu✗ mv 'test[].txt' 'test2.txt'
Error:
× File(s) not found
╭─[entry #33:1:1]
1 │ mv 'test[].txt' 'test2.txt'
· ──────┬─────
· ╰── could not find any files matching this glob pattern
╰────
the same happens if the [ ] is in the directory name:
nu✗ ls **/*
╭───┬───────────────────┬──────┬──────┬────────────────╮
│ # │ name │ type │ size │ modified │
├───┼───────────────────┼──────┼──────┼────────────────┤
│ 0 │ test.txt │ file │ 13 B │ 40 minutes ago │
│ 1 │ test[] │ dir │ 36 B │ 11 seconds ago │
│ 2 │ test[]/test.txt │ file │ 13 B │ 40 minutes ago │
│ 3 │ test[]/test[].txt │ file │ 13 B │ 40 minutes ago │
│ 4 │ test[].txt │ file │ 13 B │ 40 minutes ago │
╰───┴───────────────────┴──────┴──────┴────────────────╯
nu❯ ls **/* | get name | get 2 | open
Error:
× Error extracting glob pattern
╭─[entry #52:1:1]
1 │ ls **/* | get name | get 2 | open
· ──┬─
· ╰── Pattern syntax error near position 40: invalid range pattern
╰────
nu✗ open `test[]/test.txt`
Error:
× Error extracting glob pattern
╭─[entry #54:1:1]
1 │ open `test[]/test.txt`
· ──┬─
· ╰── Pattern syntax error near position 40: invalid range pattern
╰────
I did also try to see if the issue also happens with () and {} and it didn`t.
How to reproduce
try to open a file that has [] in its name.
Expected behavior
the file to be opened if it is quoted or been passed as a string from a pipe.
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.80.0 |
| branch | makepkg |
| commit_hash | 8695b57 |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.69.0 (84c898d65 2023-04-16) (Arch Linux rust 1:1.69.0-3) |
| cargo_version | cargo 1.69.0 |
| build_time | 2023-05-17 05:13:57 +00:00 |
| build_rust_channel | release |
| features | default, zip |
| installed_plugins |
Additional context
No response
Reacted by Mirage10, Cheuk Yin Ng, Ryan Olson, Aidan Gauland, Emily Grace Seville, K0ng2, equt and Felix Zeller
Metadata
Metadata
Assignees
Labels
A:file-systemRelated to commands and core nushell behavior around the file systemA:globBehavior around file-system globbing with regular commands or `glob`. See also A:quoting/expansioncategory:bugSomething isn't working
Activity
WindSoilder commentedon May 28, 2023
Here is a pr to fix it: #9307
amtoine commentedon May 28, 2023
as you suggested @WindSoilder, i've linked to #9307 👍
if it's not a fixing PR in the end, we can unlink it 😉
kurokirasama commentedon Jun 7, 2023
Just add that I get this error too:
ynhame commentedon Jun 7, 2023
I think it would help to also add the command that gave you this error.
also the nushell version would be helpfull as well
kurokirasama commentedon Jun 7, 2023
ckafi commentedon Jun 9, 2023
It seems this bug isn't limited to square brackets, but happens also with other glob patterns:
ryanolsonx commentedon Jun 14, 2023
This also happens if a directory name has [ in it. This is popular in Next.js projects where directory structure dictates route.
star-szr commentedon Aug 17, 2023
Looks like the latest related PR is #9416.
bobhy commentedon Oct 10, 2023
I believe this is also fixed by #10557.
Allow filesystem commands to access files with glob metachars in name (…
Allow filesystem commands to access files with glob metachars in name (…
Allow filesystem commands to access files with glob metachars in name (…
aidalgol commentedon Jan 11, 2024
I am able to use the built-in Nushell commands (
rm,mv,cp, etc.) on files with square brackets in the name as of Nushell0.88, so this does appear to be fixed.ckafi commentedon Jan 11, 2024
As of 0.89.0 it is not completely fixed. There is still some weirdness going on:
Similar issues exist if the path contains a glob pattern:
Unify glob behavior on `open`, `rm`, `cp-old`, `mv`, `umv`, `cp` and …
Unify glob behavior on `open`, `rm`, `cp-old`, `mv`, `umv`, `cp` and …