rc
rc copied to clipboard
Matching empty glob using a literal string is not possible
I do not know if this is a bug or if I'm just stupid. but.
cd /tmp;touch hello.mkv
for (* in *.[mM][Kk][vV] *.[Mm][Pp]4){ ~ $^* '*'.* || echo $* }
should match *.[Mm][Pp]4, however it doesn't, there is a workaround, using ~ $* [*].*
but I find it strange that quoting a * does not yield the correct result. 9rc also suffers from this.
It works for me as expected, and there is no difference whether I use '*'.*
or [*].*
.
Here is what happens for me:
-
*.[mM][Kk][vV]
expands tohello.mkv
. -
hello.mkv
does not match the pattern'*'.*
, so~
fails andhello.mkv
is printed. -
*.[Mm][Pp]4
does not match any file names, so it is not expanded. -
*.[Mm][Pp]4
matches the pattern'*'.*
, so~
succeeds (and nothing is printed).
This is not a bug. The provided snippet works as expected just like @memreflect explained.