The last execution of -exec {} + is not done if the -exec primary is

not on the top-level -and sequence, e.g. inside of ! or -or.

Create a separate linked list of all active -exec {} + primaries and
do the last execution for all at termination.

PR:		bin/79263
Submitted by:	Jilles Tjoelker <jilles@stack.nl>
MFC after:	7 days
This commit is contained in:
Kirill Ponomarev 2006-05-14 20:23:01 +00:00
parent 07399d81d8
commit 22170420ec
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=158572
4 changed files with 21 additions and 4 deletions

View File

@ -49,6 +49,7 @@ struct stat;
void printlong(char *, char *, struct stat *);
int queryuser(char **);
OPTION *lookup_option(const char *);
void finish_execplus(void);
creat_f c_Xmin;
creat_f c_Xtime;

View File

@ -231,10 +231,7 @@ find_execute(PLAN *plan, char *paths[])
*/
for (p = plan; p && (p->execute)(p, entry); p = p->next);
}
/* Finish any pending -exec ... {} + functions. */
for (p = plan; p != NULL; p = p->next)
if (p->execute == f_exec && p->flags & F_EXECPLUS)
(p->execute)(p, NULL);
finish_execplus();
if (errno)
err(1, "fts_read");
return (rval);

View File

@ -105,6 +105,7 @@ typedef struct _plandata {
int _e_psize; /* number of bytes of args. */
int _e_pbsize; /* base num. of bytes of args */
int _e_psizemax; /* max num. of bytes of args */
struct _plandata *_e_next;/* next F_EXECPLUS in tree */
} ex;
char *_a_data[2]; /* array of char pointers */
char *_c_data; /* char pointer */
@ -135,6 +136,7 @@ typedef struct _plandata {
#define e_psize p_un.ex._e_psize
#define e_pbsize p_un.ex._e_pbsize
#define e_psizemax p_un.ex._e_psizemax
#define e_next p_un.ex._e_next
typedef struct _option {
const char *name; /* option name */

View File

@ -76,6 +76,8 @@ static char *nextarg(OPTION *, char ***);
extern char **environ;
static PLAN *lastexecplus = NULL;
#define COMPARE(a, b) do { \
switch (plan->flags & F_ELG_MASK) { \
case F_EQUAL: \
@ -711,6 +713,8 @@ c_exec(OPTION *option, char ***argvp)
new->e_psizemax = argmax;
new->e_pbsize = 0;
cnt += new->e_pnummax + 1;
new->e_next = lastexecplus;
lastexecplus = new;
}
if ((new->e_argv = malloc(cnt * sizeof(char *))) == NULL)
err(1, NULL);
@ -754,6 +758,19 @@ done: *argvp = argv + 1;
return new;
}
/* Finish any pending -exec ... {} + functions. */
void
finish_execplus()
{
PLAN *p;
p = lastexecplus;
while (p != NULL) {
(p->execute)(p, NULL);
p = p->e_next;
}
}
int
f_flags(PLAN *plan, FTSENT *entry)
{