Please find enclosed a patch that implements -lname and -ilname in
FreeBSD's find.  There's some shell scripts that insist on these gnu
findtools features.

Comments?

Warner

Index: find.1
===================================================================
RCS file: /cache/ncvs/src/usr.bin/find/find.1,v
retrieving revision 1.82
diff -u -r1.82 find.1
--- find.1      28 Feb 2007 10:19:25 -0000      1.82
+++ find.1      23 Feb 2008 05:57:30 -0000
@@ -436,6 +436,10 @@
 is numeric and there is no such group name, then
 .Ar gname
 is treated as a group ID.
+.It Ic -ilname Ar pattern
+Like
+.Ic -lname ,
+but the match is case insensitive.
 .It Ic -iname Ar pattern
 Like
 .Ic -name ,
@@ -455,6 +459,10 @@
 True if the file has
 .Ar n
 links.
+.It Ic -lname Ar pattern
+Like
+.Ic -name ,
+but the must also be a symbolic link.
 .It Ic -ls
 This primary always evaluates to true.
 The following information for the current file is written to standard output:
Index: find.h
===================================================================
RCS file: /cache/ncvs/src/usr.bin/find/find.h,v
retrieving revision 1.19
diff -u -r1.19 find.h
--- find.h      14 May 2006 20:23:01 -0000      1.19
+++ find.h      22 Feb 2008 19:38:21 -0000
@@ -74,6 +74,7 @@
 #define F_EXECPLUS     0x00020000      /* -exec ... {} + */
 #define        F_TIME_B        0x00040000      /* one of -Btime, -Bnewer, 
-newerB* */
 #define        F_TIME2_B       0x00080000      /* one of -newer?B */
+#define F_LINK         0x00100000      /* lname or liname */
 
 /* node definition */
 typedef struct _plandata {
Index: function.c
===================================================================
RCS file: /cache/ncvs/src/usr.bin/find/function.c,v
retrieving revision 1.58
diff -u -r1.58 function.c
--- function.c  27 May 2006 18:27:41 -0000      1.58
+++ function.c  22 Feb 2008 19:50:13 -0000
@@ -1063,6 +1063,8 @@
 int
 f_name(PLAN *plan, FTSENT *entry)
 {
+       if ((plan->flags & F_LINK) && !S_ISLNK(entry->fts_statp->st_mode))
+               return 0;
        return !fnmatch(plan->c_data, entry->fts_name,
            plan->flags & F_IGNCASE ? FNM_CASEFOLD : 0);
 }
@@ -1076,6 +1078,8 @@
        pattern = nextarg(option, argvp);
        new = palloc(option);
        new->c_data = pattern;
+       if (new->flags & F_LINK)
+               ftsoptions &= ~FTS_NOSTAT;
        return new;
 }
 
Index: option.c
===================================================================
RCS file: /cache/ncvs/src/usr.bin/find/option.c,v
retrieving revision 1.25
diff -u -r1.25 option.c
--- option.c    5 Apr 2006 23:06:11 -0000       1.25
+++ option.c    22 Feb 2008 19:37:33 -0000
@@ -88,7 +88,9 @@
        { "-inum",      c_inum,         f_inum,         0 },
        { "-ipath",     c_name,         f_path,         F_IGNCASE },
        { "-iregex",    c_regex,        f_regex,        F_IGNCASE },
+       { "-liname",    c_name,         f_name,         F_LINK | F_IGNCASE },
        { "-links",     c_links,        f_links,        0 },
+       { "-lname",     c_name,         f_name,         F_LINK },
        { "-ls",        c_ls,           f_ls,           0 },
        { "-maxdepth",  c_mXXdepth,     f_always_true,  F_MAXDEPTH },
        { "-mindepth",  c_mXXdepth,     f_always_true,  0 },
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to