From d1c3dd9b1997e5fa7ac836f787f68db840ae690a Mon Sep 17 00:00:00 2001 From: op Date: Tue, 28 Mar 2023 08:01:40 +0000 Subject: [PATCH] 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@ --- usr.bin/mg/region.c | 8 ++++---- 1 file 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 #include #include +#include #include #include #include @@ -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); -- 2.20.1