Print this page
12328 FNMPERIOD makes little sense for find -path

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/find/find.c
          +++ new/usr/src/cmd/find/find.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  24   24   * Copyright (c) 2013 Andrew Stormont.  All rights reserved.
       25 + * Copyright 2020 Joyent, Inc.
  25   26   */
  26   27  
  27   28  
  28   29  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  29   30  /*        All Rights Reserved   */
  30   31  
  31   32  
  32   33  /*      Parts of this product may be derived from               */
  33   34  /*      Mortice Kern Systems Inc. and Berkeley 4.3 BSD systems. */
  34   35  /*      licensed from  Mortice Kern Systems Inc. and            */
↓ open down ↓ 985 lines elided ↑ open up ↑
1020 1021                                      gettext("%s: cannot strdup() %s: %s\n"),
1021 1022                                      cmdname, name, strerror(errno));
1022 1023                                  exit(2);
1023 1024                          }
1024 1025                          /*
1025 1026                           * XPG4 find should not treat a leading '.' in a
1026 1027                           * filename specially for pattern matching.
1027 1028                           * /usr/bin/find  will not pattern match a leading
1028 1029                           * '.' in a filename, unless '.' is explicitly
1029 1030                           * specified.
     1031 +                         *
     1032 +                         * The legacy behavior makes no sense for PATH.
1030 1033                           */
1031 1034  #ifndef XPG4
1032      -                        fnmflags |= FNM_PERIOD;
     1035 +                        if (np->action == NAME || np->action == INAME)
     1036 +                                fnmflags |= FNM_PERIOD;
1033 1037  #endif
1034 1038  
1035 1039                          val = !fnmatch(np->first.cp,
1036 1040                              (np->action == NAME || np->action == INAME) ?
1037 1041                              basename(path) : path, fnmflags);
1038 1042                          free(path);
1039 1043                          break;
1040 1044                  }
1041 1045  
1042 1046                  case PRUNE:
↓ open down ↓ 1224 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX