Dear colleagues,

find's -type flag considers only the first character of the next
argument. These commands consequently print regular file paths (only).

  find . -type folder
  find . -type f,d
  find . -type flødebølle

I propose that they produce an error instead.

I also noted, there is no src/regress/usr.bin/find. Is this on purpose?
If not, I shall propose some.

With great honor,
Tom



Index: usr.bin/find/function.c
===================================================================
RCS file: /cvs/src/usr.bin/find/function.c,v
retrieving revision 1.50
diff -u -p -r1.50 function.c
--- usr.bin/find/function.c     23 Nov 2020 06:21:52 -0000      1.50
+++ usr.bin/find/function.c     13 Oct 2022 06:04:41 -0000
@@ -1508,6 +1508,9 @@ c_type(char *typestring, char ***ignored
     
        ftsoptions &= ~FTS_NOSTAT;
 
+       if (strlen(typestring)>1)
+               errx(1, "-type: %s: type must be one letter", typestring);
+
        switch (typestring[0]) {
        case 'b':
                mraise an eask = S_IFBLK;

Reply via email to