diff options
author | Omar Polo <op@cvs.openbsd.org> | 2023-03-28 08:01:41 +0000 |
---|---|---|
committer | Omar Polo <op@cvs.openbsd.org> | 2023-03-28 08:01:41 +0000 |
commit | 87d0c52b664aa53d3b44e615fb2bc1c2e9d44ce1 (patch) | |
tree | 310489e401623eafbc3b7725f64e36dbc0305d2b /usr.bin | |
parent | c4a562fca2f2bffd5a966c63b1bb22805180e7a0 (diff) |
mg: fall back to /bin/sh if $SHELL is undefined.
Original diff from lux (lx [at] shellcodes [dot] org) thanks!
tweaked by me; ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/region.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c index f94a5f64d00..536c24c1b6d 100644 --- a/usr.bin/mg/region.c +++ b/usr.bin/mg/region.c @@ -1,4 +1,4 @@ -/* $OpenBSD: region.c,v 1.42 2023/03/27 17:54:20 op Exp $ */ +/* $OpenBSD: region.c,v 1.43 2023/03/28 08:01:40 op Exp $ */ /* This file is in the public domain. */ @@ -15,6 +15,7 @@ #include <sys/wait.h> #include <errno.h> #include <fcntl.h> +#include <paths.h> #include <poll.h> #include <signal.h> #include <stdio.h> @@ -483,7 +484,8 @@ shellcmdoutput(char* const argv[], char* const text, int len) return (FALSE); } - shellp = getenv("SHELL"); + if ((shellp = getenv("SHELL")) == NULL) + shellp = _PATH_BSHELL; ret = pipeio(shellp, argv, text, len, bp); @@ -530,8 +532,6 @@ pipeio(const char* const path, char* const argv[], char* const text, int len, _exit(1); if (dup2(s[1], STDERR_FILENO) == -1) _exit(1); - if (path == NULL) - _exit(1); execv(path, argv); err = strerror(errno); |