diff options
author | Omar Polo <op@cvs.openbsd.org> | 2023-03-28 14:47:29 +0000 |
---|---|---|
committer | Omar Polo <op@cvs.openbsd.org> | 2023-03-28 14:47:29 +0000 |
commit | 40633d42df78562c9239464c9b4dd8569c2ac280 (patch) | |
tree | 6be45d09ddfeb7a9769de2289a611f57f21b45c8 /usr.bin/mg | |
parent | 0bde7544534eab4979ecb2de5d2ecab149fc1539 (diff) |
use the shell basename as argv[0] instead of hardcoding "sh"
Suggested by and ok millert@, thanks!
Diffstat (limited to 'usr.bin/mg')
-rw-r--r-- | usr.bin/mg/region.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c index 536c24c1b6d..afed531eb0a 100644 --- a/usr.bin/mg/region.c +++ b/usr.bin/mg/region.c @@ -1,4 +1,4 @@ -/* $OpenBSD: region.c,v 1.43 2023/03/28 08:01:40 op Exp $ */ +/* $OpenBSD: region.c,v 1.44 2023/03/28 14:47:28 op Exp $ */ /* This file is in the public domain. */ @@ -34,7 +34,7 @@ static int iomux(int, char * const, int, struct buffer *); static int preadin(int, struct buffer *); static void pwriteout(int, char **, int *); static int setsize(struct region *, RSIZE); -static int shellcmdoutput(char * const[], char * const, int); +static int shellcmdoutput(char * const, char * const, int); /* * Kill the region. Ask "getregion" to figure out the bounds of the region. @@ -415,7 +415,6 @@ piperegion(int f, int n) struct region region; int len; char *cmd, cmdbuf[NFILEN], *text; - char *argv[] = {"sh", "-c", (char *) NULL, (char *) NULL}; /* C-u M-| is not supported yet */ if (n > 1) @@ -431,8 +430,6 @@ piperegion(int f, int n) EFNEW | EFCR)) == NULL || (cmd[0] == '\0')) return (ABORT); - argv[2] = cmd; - if (getregion(®ion) != TRUE) return (FALSE); @@ -446,7 +443,7 @@ piperegion(int f, int n) region_get_data(®ion, text, len); - return shellcmdoutput(argv, text, len); + return shellcmdoutput(cmd, text, len); } /* @@ -456,7 +453,6 @@ int shellcommand(int f, int n) { char *cmd, cmdbuf[NFILEN]; - char *argv[] = {"sh", "-c", (char *) NULL, (char *) NULL}; if (n > 1) return (ABORT); @@ -465,15 +461,14 @@ shellcommand(int f, int n) EFNEW | EFCR)) == NULL || (cmd[0] == '\0')) return (ABORT); - argv[2] = cmd; - - return shellcmdoutput(argv, NULL, 0); + return shellcmdoutput(cmd, NULL, 0); } int -shellcmdoutput(char* const argv[], char* const text, int len) +shellcmdoutput(char* const cmd, char* const text, int len) { struct buffer *bp; + char *argv[] = {NULL, "-c", cmd, NULL}; char *shellp; int ret; @@ -487,6 +482,11 @@ shellcmdoutput(char* const argv[], char* const text, int len) if ((shellp = getenv("SHELL")) == NULL) shellp = _PATH_BSHELL; + if ((argv[0] = strrchr(shellp, '/')) != NULL) + argv[0]++; + else + argv[0] = shellp; + ret = pipeio(shellp, argv, text, len, bp); if (ret == TRUE) { |