From 33f04551f3c9a5182aabe9dfe36d6a0b88298686 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 21 Mar 2015 17:15:09 -0500 Subject: 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 '{}' ';' --- toys/posix/find.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'toys/posix/find.c') diff --git a/toys/posix/find.c b/toys/posix/find.c index 3607874a..69e370d4 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -435,7 +435,7 @@ static int do_find(struct dirtree *new) 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 @@ static int do_find(struct dirtree *new) 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') { -- cgit v1.2.3