From 5da68ee193728197639092241855ef653c186bf1 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Tue, 29 Nov 2005 05:21:06 +0000 Subject: [PATCH] in execute_command(), instead of hardcoding /bin/sh as the shell to use when executing a command, use $SHELL, and only fall back to /bin/sh if $SHELL isn't set git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3220 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 4 ++++ src/text.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e7ddb7e5..c47f58fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -185,6 +185,10 @@ CVS code - - Only include the whole_word parameter when DISABLE_SPELLER isn't defined, as it's only used then. (DLR) - text.c: + execute_command() + - Instead of hardcoding /bin/sh as the shell to use when + executing a command, use $SHELL, and only fall back to /bin/sh + if $SHELL isn't set. (DLR) do_wrap() - Rename variable wrapping to prepending, to avoid confusion, and rename the static bool same_line_wrap to prepend_wrap to diff --git a/src/text.c b/src/text.c index 67db002a..3af87948 100644 --- a/src/text.c +++ b/src/text.c @@ -271,12 +271,20 @@ bool execute_command(const char *command) /* Fork a child. */ if ((pid = fork()) == 0) { + char *shellenv; + close(fd[0]); dup2(fd[1], fileno(stdout)); dup2(fd[1], fileno(stderr)); + /* Check $SHELL for the shell to use. If it isn't set, use + * /bin/sh. */ + shellenv = getenv("SHELL"); + if (shellenv == NULL) + shellenv = "/bin/sh"; + /* If execl() returns at all, there was an error. */ - execl("/bin/sh", "sh", "-c", command, NULL); + execl(shellenv, tail(shellenv), "-c", command, NULL); exit(0); } -- 2.39.5