[gnome-builder] project-tree: attempt to preserve proper $SHELL for terminal



commit db891a1463ad1d5af7187f758f58ace552acf68c
Author: Christian Hergert <christian hergert me>
Date:   Tue Jun 9 23:47:37 2015 -0700

    project-tree: attempt to preserve proper $SHELL for terminal
    
    If we set $SHELL to vte_get_user_shell(), gnome-terminal will spawn with
    the appropriate shell instead of /bin/sh.

 src/project-tree/gb-project-tree-actions.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/project-tree/gb-project-tree-actions.c b/src/project-tree/gb-project-tree-actions.c
index d4341d0..353e16b 100644
--- a/src/project-tree/gb-project-tree-actions.c
+++ b/src/project-tree/gb-project-tree-actions.c
@@ -20,6 +20,7 @@
 
 #include <glib/gi18n.h>
 #include <gio/gdesktopappinfo.h>
+#include <vte/vte.h>
 
 #include "gb-editor-workspace.h"
 #include "gb-file-manager.h"
@@ -294,7 +295,9 @@ gb_project_tree_actions_open_in_terminal (GSimpleAction *action,
   GFile *file;
   g_autofree gchar *workdir = NULL;
   g_autofree gchar *terminal_executable = NULL;
+  g_autofree gchar *shell = NULL;
   const gchar *argv[] = { NULL, NULL };
+  g_auto(GStrv) env = NULL;
   GError *error = NULL;
 
   g_assert (GB_IS_PROJECT_TREE (self));
@@ -340,10 +343,18 @@ gb_project_tree_actions_open_in_terminal (GSimpleAction *action,
   argv[0] = terminal_executable;
   g_return_if_fail (terminal_executable != NULL);
 
+  /*
+   * Overwrite SHELL to the users default shell.
+   * Failure to do so typically results in /bin/sh being used.
+   */
+  shell = vte_get_user_shell ();
+  g_setenv ("SHELL", shell, TRUE);
+  env = g_get_environ ();
+
   /* Can't use GdkAppLaunchContext as
    * we cannot set the working directory.
    */
-  if (!g_spawn_async (workdir, (gchar **)argv, NULL,
+  if (!g_spawn_async (workdir, (gchar **)argv, env,
                       G_SPAWN_STDERR_TO_DEV_NULL,
                       NULL, NULL, NULL, &error))
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]