Use execl in both paths and the same warn() call --- usr.bin/script/script.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c index 763975d6a..fd2829033 100644 --- a/usr.bin/script/script.c +++ b/usr.bin/script/script.c @@ -313,10 +313,7 @@ scriptflush(int signo) void doshell(char *cmd) { - char *shell; - char *argp[] = {"sh", "-c", NULL, NULL}; - - shell = getenv("SHELL"); + const char *shell = cmd ? NULL : getenv("SHELL"); if (shell == NULL) shell = _PATH_BSHELL; @@ -324,14 +321,12 @@ doshell(char *cmd) (void)fclose(fscript); login_tty(slave); - if (cmd != NULL) { - argp[2] = cmd; - execv(_PATH_BSHELL, argp); - warn("unable to execute %s", _PATH_BSHELL); - } else { + if (cmd != NULL) + execl(shell, "sh", "-c", cmd, (char *)NULL); + else execl(shell, shell, "-i", (char *)NULL); - warn("%s", shell); - } + + warn("unable to execute %s", shell); fail(); } -- 2.30.2
signature.asc
Description: PGP signature