rc icon indicating copy to clipboard operation
rc copied to clipboard

Matching empty glob using a literal string is not possible

Open Nomarian opened this issue 3 years ago • 1 comments

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.

Nomarian avatar Mar 09 '21 22:03 Nomarian

It works for me as expected, and there is no difference whether I use '*'.* or [*].*.

Here is what happens for me:

  1. *.[mM][Kk][vV] expands to hello.mkv.
  2. hello.mkv does not match the pattern '*'.*, so ~ fails and hello.mkv is printed.
  3. *.[Mm][Pp]4 does not match any file names, so it is not expanded.
  4. *.[Mm][Pp]4 matches the pattern '*'.*, so ~ succeeds (and nothing is printed).

memreflect avatar May 11 '21 21:05 memreflect

This is not a bug. The provided snippet works as expected just like @memreflect explained.

xyb3rt avatar Jun 11 '23 12:06 xyb3rt