bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[find] enable paths starting with a comma


From: Michael Teichgräber
Subject: [find] enable paths starting with a comma
Date: Sat, 02 Aug 2003 19:09:42 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.2 (gnu/linux)

Hello,

`find [FILE...] [EXPRESSION]' does not allow FILE to begin with a
comma, since this is a member of a list of characters that are
operators, or prefixes of functions: "-!(),".

Since the time I have been using Tom Lord's arch RCS, I have got used to
sometimes prepend the names of temporary "junk" files and directories
with `,'. At the moment `find ,foo -type f' would not work, because of

    find: invalid predicate `,foo'.

In find/find.c there are two for-loops that determine the beginning of
predicates within the argument list by means of comparing the command
line arguments' first characters with the list "-!(),".

If I'm not wrong, in a correct "find" call the comma operator wouldn't
be located at the first position, since an operand to it must come
first. So if `,' would be removed from these lists, it would be
possible to run e.g.

    find ,foo -type f

, and `,' still would work as an operator.

In case you are interested, I have provided a patch (diffed against
CVS head) that removes `,' from those two for-loops in find.c and
updates find.texi and the man-page.

Since I don't know much about the internals of "find", I might have
missed something that will get broken by this change. But, as I've
tested on an example (find ,foo -exec echo -n . \; , -type d -print),
the comma operator was, at least for that, still working :-)


Regards,

-- 
Michael

Index: doc/find.texi
===================================================================
RCS file: /cvsroot/findutils/findutils/doc/find.texi,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 find.texi
--- doc/find.texi       21 Jun 2003 09:15:15 -0000      1.17
+++ doc/find.texi       2 Aug 2003 16:13:52 -0000
@@ -2058,7 +2058,7 @@ find @address@hidden@address@hidden @address@hidden
 the tree.
 
 @code{find} considers the first argument that begins with @samp{-},
address@hidden(}, @samp{)}, @samp{,}, or @samp{!} to be the beginning of the
address@hidden(}, @samp{)}, or @samp{!} to be the beginning of the
 expression; any arguments before it are paths to search, and any
 arguments after it are the rest of the expression.  If no paths are
 given, the current directory is used.  If no expression is given, the
Index: find/find.1
===================================================================
RCS file: /cvsroot/findutils/findutils/find/find.1,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 find.1
--- find/find.1 2 Aug 2003 15:26:20 -0000       1.8
+++ find/find.1 2 Aug 2003 16:13:53 -0000
@@ -17,7 +17,7 @@ known (the left hand side is false for \
 .B find
 moves on to the next file name.
 .PP
-The first argument that begins with `\-', `(', `)', `,', or `!' is taken
+The first argument that begins with `\-', `(', `)', or `!' is taken
 to be the beginning of the expression; any arguments before it are
 paths to search, and any arguments after it are the rest of the
 expression.  If no paths are given, the current directory is used.  If
Index: find/find.c
===================================================================
RCS file: /cvsroot/findutils/findutils/find/find.c,v
retrieving revision 1.11
diff -u -p -u -p -r1.11 find.c
--- find/find.c 14 Jun 2003 15:41:26 -0000      1.11
+++ find/find.c 2 Aug 2003 16:13:54 -0000
@@ -199,7 +199,7 @@ main (int argc, char **argv)
 #endif /* DEBUG */
 
   /* Find where in ARGV the predicates begin. */
-  for (i = 1; i < argc && strchr ("-!(),", argv[i][0]) == NULL; i++)
+  for (i = 1; i < argc && strchr ("-!()", argv[i][0]) == NULL; i++)
     /* Do nothing. */ ;
 
   /* Enclose the expression in `( ... )' so a default -print will
@@ -290,7 +290,7 @@ main (int argc, char **argv)
     error (1, errno, _("cannot get current directory"));
 
   /* If no paths are given, default to ".".  */
-  for (i = 1; i < argc && strchr ("-!(),", argv[i][0]) == NULL; i++)
+  for (i = 1; i < argc && strchr ("-!()", argv[i][0]) == NULL; i++)
     process_top_path (argv[i]);
   if (i == 1)
     process_top_path (".");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]