i3 - improved tiling WM


Use _PATH_BSHELL to ensure using a bourne shell

Patch status: merged

Patch by Baptiste Daroussin

To apply this patch, use:
curl http://cr.i3wm.org/patch/297/raw.patch | git am

b/i3-nagbar/main.c

15
@@ -22,6 +22,7 @@
16
 #include <getopt.h>
17
 #include <limits.h>
18
 #include <fcntl.h>
19
+#include <paths.h>
20
 
21
 #include <xcb/xcb.h>
22
 #include <xcb/xcb_aux.h>
23
@@ -95,15 +96,8 @@ static void start_application(const char *command) {
24
         /* Child process */
25
         setsid();
26
         if (fork() == 0) {
27
-            /* Stores the path of the shell */
28
-            static const char *shell = NULL;
29
-
30
-            if (shell == NULL)
31
-                if ((shell = getenv("SHELL")) == NULL)
32
-                    shell = "/bin/sh";
33
-
34
             /* This is the child */
35
-            execl(shell, shell, "-c", command, (void*)NULL);
36
+            execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (void*)NULL);
37
             /* not reached */
38
         }
39
         exit(0);

b/i3bar/src/child.c

44
@@ -22,6 +22,7 @@
45
 #include <yajl/yajl_parse.h>
46
 #include <yajl/yajl_version.h>
47
 #include <yajl/yajl_gen.h>
48
+#include <paths.h>
49
 
50
 #include "common.h"
51
 
52
@@ -423,12 +424,7 @@ void start_child(char *command) {
53
                 dup2(pipe_in[1], STDOUT_FILENO);
54
                 dup2(pipe_out[0], STDIN_FILENO);
55
 
56
-                static const char *shell = NULL;
57
-
58
-                if ((shell = getenv("SHELL")) == NULL)
59
-                    shell = "/bin/sh";
60
-
61
-                execl(shell, shell, "-c", command, (char*) NULL);
62
+                execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (char*) NULL);
63
                 return;
64
             default:
65
                 /* Parent-process. Reroute streams */

b/src/startup.c

70
@@ -17,6 +17,7 @@
71
 
72
 #include <sys/types.h>
73
 #include <sys/wait.h>
74
+#include <paths.h>
75
 
76
 #define SN_API_NOT_YET_FROZEN 1
77
 #include <libsn/sn-launcher.h>
78
@@ -191,15 +192,7 @@ void start_application(const char *command, bool no_startup_id) {
79
             if (!no_startup_id)
80
                 sn_launcher_context_setup_child_process(context);
81
 
82
-            /* Stores the path of the shell */
83
-            static const char *shell = NULL;
84
-
85
-            if (shell == NULL)
86
-                if ((shell = getenv("SHELL")) == NULL)
87
-                    shell = "/bin/sh";
88
-
89
-            /* This is the child */
90
-            execl(shell, shell, "-c", command, (void*)NULL);
91
+            execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (void*)NULL);
92
             /* not reached */
93
         }
94
         _exit(0);