changeset 1747:3297b4b490f8

Another bug from David Halls: find -exec wasn't consuming its argument when it didn't activate. test: find . -name README -exec echo one '{}' ';' -or -exec echo two '{}' ';'
author Rob Landley <rob@landley.net>
date Sat, 21 Mar 2015 17:15:09 -0500
parents b11f536bac74
children 6f107e78cd9d
files toys/posix/find.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/toys/posix/find.c	Sat Mar 21 15:49:38 2015 -0500
+++ b/toys/posix/find.c	Sat Mar 21 17:15:09 2015 -0500
@@ -435,7 +435,7 @@
           if (aa->dir && TT.topdir == -1) TT.topdir = xopen(".", 0);
 
         // collect names and execute commands
-        } else if (check) {
+        } else {
           char *name, *ss1 = ss[1];
           struct double_list **ddl;
 
@@ -443,11 +443,12 @@
           aa = (void *)llist_pop(&argdata);
           ss += aa->arglen + 1;
 
+          if (!check) goto cont;
           // name is always a new malloc, so we can always free it.
           name = aa->dir ? xstrdup(new->name) : dirtree_path(new, 0);
 
           // Mark entry so COMEAGAIN can call flush_exec() in parent.
-          // This is never a valid pointer valud for prev to have otherwise
+          // This is never a valid pointer value for prev to have otherwise
           if (aa->dir) aa->prev = (void *)1;
 
           if (*s == 'o') {