ash: fix build failure when command built-in is disabled

Since commit 7eb8eecbb (ash: eval: Add assignment built-in support
again) building BusyBox with the 'command' built-in disabled fails.

parse_command_args() only needs to be called when the 'command'
built-in is run.  Which it won't be if it's disabled.

v2: Avoiding infinite loops is good, too.  Thanks, Harald van Dijk.

Reported-by: Deweloper <deweloper@wp.pl>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Ron Yorston 2020-02-27 09:50:18 +00:00 committed by Denys Vlasenko
parent d1b75e1842
commit da7a6dbfa5

View File

@ -8675,7 +8675,6 @@ typecmd(int argc UNUSED_PARAM, char **argv)
return err; return err;
} }
#if ENABLE_ASH_CMDCMD
static struct strlist * static struct strlist *
fill_arglist(struct arglist *arglist, union node **argpp) fill_arglist(struct arglist *arglist, union node **argpp)
{ {
@ -8692,6 +8691,7 @@ fill_arglist(struct arglist *arglist, union node **argpp)
return *lastp; return *lastp;
} }
#if ENABLE_ASH_CMDCMD
/* Is it "command [-p] PROG ARGS" bltin, no other opts? Return ptr to "PROG" if yes */ /* Is it "command [-p] PROG ARGS" bltin, no other opts? Return ptr to "PROG" if yes */
static int static int
parse_command_args(struct arglist *arglist, union node **argpp, const char **path) parse_command_args(struct arglist *arglist, union node **argpp, const char **path)
@ -10190,11 +10190,13 @@ evalcommand(union node *cmd, int flags)
vlocal = !spclbltin; vlocal = !spclbltin;
} }
cmd_is_exec = cmdentry.u.cmd == EXECCMD; cmd_is_exec = cmdentry.u.cmd == EXECCMD;
#if ENABLE_ASH_CMDCMD
if (cmdentry.u.cmd != COMMANDCMD) if (cmdentry.u.cmd != COMMANDCMD)
break; break;
cmd_flag = parse_command_args(&arglist, &argp, &path); cmd_flag = parse_command_args(&arglist, &argp, &path);
if (!cmd_flag) if (!cmd_flag)
#endif
break; break;
} }