Hi all,

I misread find(1) and did:

[weerdpom] $ find path/to/cam -name \*.JPG -exec cp {} path/to/store +
find: -exec no terminating ";" or "+"

That was somewhat surprising - there is a terminating "+".  The error
really is that the "+" doesn't follow immediately after the "{}"
(which the manpage of course told me).  Although it would be nice to
be able to use tools like cp and mv to -exec with +, I suspect there
to be dragons.  So I'm proposing to change the error to point this out
to the unsuspecting user.

Cheers,

Paul 'WEiRD' de Weerd

Index: function.c
===================================================================
RCS file: /home/OpenBSD/cvs/src/usr.bin/find/function.c,v
retrieving revision 1.49
diff -u -p -r1.49 function.c
--- function.c  9 Apr 2020 15:07:49 -0000       1.49
+++ function.c  12 Nov 2020 19:42:49 -0000
@@ -572,9 +572,14 @@ c_exec(char *unused, char ***argvp, int 
                        brace = 1;
                if (strcmp(*ap, ";") == 0)
                        break;
-               if (strcmp(*ap, "+") == 0 && lastbrace) {
-                       new->flags |= F_PLUSSET;
-                       break;
+               if (strcmp(*ap, "+") == 0) {
+                       if (lastbrace) {
+                               new->flags |= F_PLUSSET;
+                               break;
+                       } else {
+                               errx(1, "%s: \"+\" should follow {}",
+                                  isok ? "-ok" : "-exec");
+                       }
                }
        }
 

-- 
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
                 http://www.weirdnet.nl/                 

Reply via email to