You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error: File(s) not found when the name contains square brackets #10749
A:globBehavior around file-system globbing with regular commands or `glob`. See also A:quoting/expansionstatus:needs-triageAn issue that hasn't had any proper look
There is a new version 9 hours ago and I haven't tried it yet but still I see this as counter-intuitive.
First, according to the documentation backtick-quoted and single-quoted strings don't do anything to the text they're given and escapes are none for them. the square brackets are not even mentioned as escape characters there.
Second, this is counter-intuitive at least for Bourne-shell born human beings.
I have PR #10571 pending which would work the way you want.
But before that PR is merged, @fdncred is correct -- you must escape glob metacharacters using glob quoting (which is [x], a character class that matches only 1 character). This does work as mentioned in recent builds.
This behavior is different from bash, where the shell expands globs so you use shell escapes to quote metachars. In nushell, it's the individual command that decides whether to treat its argument as a glob pattern, so the single quotes only ensured none of the metacharacters were treated as Nushell tokens and you still need to tell rm that you don't want the glob expanded.
Yes, `ls` uses a slightly different glob than `rm`, `cp`, `mv`, and the
`glob` command itself! I'm not sure this is best. After all, traditional
shells have just one. But I wanted to fix the`rm` scenario in particular,
so I left `ls` as is.
A:globBehavior around file-system globbing with regular commands or `glob`. See also A:quoting/expansionstatus:needs-triageAn issue that hasn't had any proper look
Activity
fdncred commentedon Oct 18, 2023
You have to escape glob characters. I think
rm '[[]23].mp4'would probably work.munzirtaha commentedon Oct 18, 2023
No, it doesn't work.
fdncred commentedon Oct 18, 2023
No issues with the latest version.

munzirtaha commentedon Oct 18, 2023
There is a new version 9 hours ago and I haven't tried it yet but still I see this as counter-intuitive.
First, according to the documentation backtick-quoted and single-quoted strings don't do anything to the text they're given and escapes are none for them. the square brackets are not even mentioned as escape characters there.
Second, this is counter-intuitive at least for Bourne-shell born human beings.
bobhy commentedon Oct 18, 2023
I have PR #10571 pending which would work the way you want.
But before that PR is merged, @fdncred is correct -- you must escape glob metacharacters using glob quoting (which is
[x], a character class that matches only 1 character). This does work as mentioned in recent builds.This behavior is different from bash, where the shell expands globs so you use shell escapes to quote metachars. In nushell, it's the individual command that decides whether to treat its argument as a glob pattern, so the single quotes only ensured none of the metacharacters were treated as Nushell tokens and you still need to tell
rmthat you don't want the glob expanded.mb21 commentedon Oct 18, 2023
Thansk @bobhy for your PR, that sounds indeed promising.
I also just ran into this. Where is it documented what globs there are and that you can escape them with
[]? Didn't see anything here: https://www.nushell.sh/book/moving_around.html#glob-patterns-wildcardsP.S. Especially confusing since tabbing seems to auto-complete it wrongly.
bobhy commentedon Oct 18, 2023
Yep, no glob documentation in the book, perhaps you'd like to take a crack at writing it?
Globbing for command arguments is done by an integrated fork of crate glob, their documentation is here: https://docs.rs/glob/0.3.1/glob/struct.Pattern.html
FYI, and just to avoid potential confusion, the
globcommand uses a different, and more powerful, crate, wax.fdncred commentedon Oct 18, 2023
or our crate docs https://docs.rs/nu-glob/latest/nu_glob/struct.Pattern.html
amtoine commentedon Oct 18, 2023
actually, PR is #10694 and issue is #10571 😉
amtoine commentedon Oct 18, 2023
if #10694 does not solve this issue, please let me know 😌
munzirtaha commentedon Oct 18, 2023
Thanks all for the constructive and quick responses
mb21 commentedon Oct 23, 2023
here you go :) nushell/nushell.github.io#1125
mb21 commentedon Oct 23, 2023
@bobhy is it possible that #10694 omitted to fix the
lscommand? I just tried latest main and while I canrm '[23].mp4', I cannotls '[23].mp4'.Also, tab-completion still completes to the wrong (unescaped) output (should I open a new issue for that?):
Screen.Recording.2023-10-23.at.14.51.59.mov
bobhy commentedon Oct 23, 2023