From: Baptiste Daroussin Date: Fri, 8 Nov 2013 20:13:35 +0000 (+0100) Subject: Use _PATH_BSHELL to ensure using a bourne shell X-Git-Tag: 4.7~27 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f691a55923850a4d315450925fc98733d07b69c9;p=i3%2Fi3 Use _PATH_BSHELL to ensure using a bourne shell [Michael] This commit should fix problems with people using a non-bourne shell as login shell, e.g. fish or rc. AFAICT, $SHELL should only be used for interactive shells, but we just want a bourne shell, not an interactive shell. --- diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c index f7a44093..0fa75f8e 100644 --- a/i3-nagbar/main.c +++ b/i3-nagbar/main.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -95,15 +96,8 @@ static void start_application(const char *command) { /* Child process */ setsid(); if (fork() == 0) { - /* Stores the path of the shell */ - static const char *shell = NULL; - - if (shell == NULL) - if ((shell = getenv("SHELL")) == NULL) - shell = "/bin/sh"; - /* This is the child */ - execl(shell, shell, "-c", command, (void*)NULL); + execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (void*)NULL); /* not reached */ } exit(0); diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 4e5e49c9..dce0218f 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "common.h" @@ -423,12 +424,7 @@ void start_child(char *command) { dup2(pipe_in[1], STDOUT_FILENO); dup2(pipe_out[0], STDIN_FILENO); - static const char *shell = NULL; - - if ((shell = getenv("SHELL")) == NULL) - shell = "/bin/sh"; - - execl(shell, shell, "-c", command, (char*) NULL); + execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (char*) NULL); return; default: /* Parent-process. Reroute streams */ diff --git a/src/startup.c b/src/startup.c index ee51664f..85e5dbc2 100644 --- a/src/startup.c +++ b/src/startup.c @@ -17,6 +17,7 @@ #include #include +#include #define SN_API_NOT_YET_FROZEN 1 #include @@ -191,15 +192,7 @@ void start_application(const char *command, bool no_startup_id) { if (!no_startup_id) sn_launcher_context_setup_child_process(context); - /* Stores the path of the shell */ - static const char *shell = NULL; - - if (shell == NULL) - if ((shell = getenv("SHELL")) == NULL) - shell = "/bin/sh"; - - /* This is the child */ - execl(shell, shell, "-c", command, (void*)NULL); + execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (void*)NULL); /* not reached */ } _exit(0);