Hi all,
It was pointed out to me off-list that I introduced a regression for
the case that has '+' as one of its arguments, e.g.:
[weerd@pom] $ find /var/empty -exec echo + {} +
find: -exec: "+" should follow {}
Updated diff fixes that case:
[weerd@pom] $ ./find /var/empty -exec echo cp {} /tmp/dest +
find: -exec: "+" should follow {}
[weerd@pom] $ ./find /var/empty -exec echo + {} +
+ /var/empty
Any thoughts or concerns? Other regressions?
Thanks,
Paul
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 15 Nov 2020 18:12:04 -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 if (!*(ap+1)) {
+ errx(1, "%s: \"+\" should follow {}",
+ isok ? "-ok" : "-exec");
+ }
}
}
On Thu, Nov 12, 2020 at 08:51:22PM +0100, Paul de Weerd wrote:
| 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/
|
--
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
http://www.weirdnet.nl/