comparison toys/posix/find.c @ 1747:3297b4b490f8 draft

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 9adb0ccb617e
children
comparison
equal deleted inserted replaced
1746:b11f536bac74 1747:3297b4b490f8
433 aa->arglen = len; 433 aa->arglen = len;
434 aa->dir = !!strchr(s, 'd'); 434 aa->dir = !!strchr(s, 'd');
435 if (aa->dir && TT.topdir == -1) TT.topdir = xopen(".", 0); 435 if (aa->dir && TT.topdir == -1) TT.topdir = xopen(".", 0);
436 436
437 // collect names and execute commands 437 // collect names and execute commands
438 } else if (check) { 438 } else {
439 char *name, *ss1 = ss[1]; 439 char *name, *ss1 = ss[1];
440 struct double_list **ddl; 440 struct double_list **ddl;
441 441
442 // Grab command line exec argument list 442 // Grab command line exec argument list
443 aa = (void *)llist_pop(&argdata); 443 aa = (void *)llist_pop(&argdata);
444 ss += aa->arglen + 1; 444 ss += aa->arglen + 1;
445 445
446 if (!check) goto cont;
446 // name is always a new malloc, so we can always free it. 447 // name is always a new malloc, so we can always free it.
447 name = aa->dir ? xstrdup(new->name) : dirtree_path(new, 0); 448 name = aa->dir ? xstrdup(new->name) : dirtree_path(new, 0);
448 449
449 // Mark entry so COMEAGAIN can call flush_exec() in parent. 450 // Mark entry so COMEAGAIN can call flush_exec() in parent.
450 // This is never a valid pointer valud for prev to have otherwise 451 // This is never a valid pointer value for prev to have otherwise
451 if (aa->dir) aa->prev = (void *)1; 452 if (aa->dir) aa->prev = (void *)1;
452 453
453 if (*s == 'o') { 454 if (*s == 'o') {
454 char *prompt = xmprintf("[%s] %s", ss1, name); 455 char *prompt = xmprintf("[%s] %s", ss1, name);
455 test = yesno(prompt, 0); 456 test = yesno(prompt, 0);