i ran into this when I was picking out files from the base sets and tried
to pick out /bin/[
: corwin; pax -zvf /home/sets/amd64/base62.tgz './bin/['
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
pax: WARNING! These patterns were not matched:
./bin/[
: corwin; pax -zvf /home/sets/amd64/base62.tgz './bin/\['
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
pax: WARNING! These patterns were not matched:
./bin/\[
: corwin; pax -zvf /home/sets/amd64/base62.tgz './bin/\\['
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
pax: WARNING! These patterns were not matched:
./bin/\\[
: corwin; pax -zvf /home/sets/amd64/base62.tgz './bin/[[]'
-r-xr-xr-x 1 root bin 112320 Sep 2 16:50 ./bin/[
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
: corwin;
Per POSIX, backslash is supposed to escape the special handling of glob
characters. With the diff below the behavior is as desired:
: corwin; obj/pax -zvf /home/sets/amd64/base62.tgz './bin/\['
-r-xr-xr-x 1 root bin 112320 Sep 2 16:50 ./bin/[
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
: corwin;
ok?
Philip
Index: pat_rep.c
===================================================================
RCS file: /data/src/openbsd/src/bin/pax/pat_rep.c,v
retrieving revision 1.41
diff -u -p -r1.41 pat_rep.c
--- pat_rep.c 26 Aug 2016 04:19:28 -0000 1.41
+++ pat_rep.c 8 Sep 2017 04:56:19 -0000
@@ -553,6 +553,9 @@ fn_match(char *pattern, char *string, ch
return (-1);
break;
case '\\':
+ if ((c = *pattern++) == '\0')
+ return (-1);
+ /* FALLTHROUGH */
default:
if (c != *string++)
return (-1);