* have to change the find_command routine as well.
* argv[-1] must exist and be writable! See tryexec() for why.
*/
-static void shellexec(char **, const char *, int) NORETURN;
-static void
-shellexec(char **argv, const char *path, int idx)
+static void shellexec(char *prog, char **argv, const char *path, int idx) NORETURN;
+static void shellexec(char *prog, char **argv, const char *path, int idx)
{
char *cmdname;
int e;
int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */
envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
- if (strchr(argv[0], '/') != NULL
+ if (strchr(prog, '/') != NULL
#if ENABLE_FEATURE_SH_STANDALONE
- || (applet_no = find_applet_by_name(argv[0])) >= 0
+ || (applet_no = find_applet_by_name(prog)) >= 0
#endif
) {
- tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) argv[0], argv, envp);
+ tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) prog, argv, envp);
if (applet_no >= 0) {
/* We tried execing ourself, but it didn't work.
* Maybe /proc/self/exe doesn't exist?
} else {
try_PATH:
e = ENOENT;
- while ((cmdname = path_advance(&path, argv[0])) != NULL) {
+ while ((cmdname = path_advance(&path, prog)) != NULL) {
if (--idx < 0 && pathopt == NULL) {
tryexec(IF_FEATURE_SH_STANDALONE(-1,) cmdname, argv, envp);
if (errno != ENOENT && errno != ENOTDIR)
}
exitstatus = exerrno;
TRACE(("shellexec failed for %s, errno %d, suppress_int %d\n",
- argv[0], e, suppress_int));
- ash_msg_and_raise(EXEXIT, "%s: %s", argv[0], errmsg(e, "not found"));
+ prog, e, suppress_int));
+ ash_msg_and_raise(EXEXIT, "%s: %s", prog, errmsg(e, "not found"));
/* NOTREACHED */
}
/*setsignal(SIGTSTP); - unnecessary because of mflag=0 */
/*setsignal(SIGTTOU); - unnecessary because of mflag=0 */
- shellexec(argv + 1, pathval(), 0);
+ shellexec(argv[1], argv + 1, pathval(), 0);
/* NOTREACHED */
}
return 0;
/* fall through to exec'ing external program */
}
listsetvar(varlist.list, VEXPORT|VSTACK);
- shellexec(argv, path, cmdentry.u.index);
+ shellexec(argv[0], argv, path, cmdentry.u.index);
/* NOTREACHED */
} /* default */
case CMDBUILTIN: