[gnome-builder] terminal: use --login with bash



commit e5faa966ba5d441c8b6e6d7f53aaf425f55d3401
Author: Christian Hergert <chergert redhat com>
Date:   Fri Aug 3 13:45:26 2018 -0700

    terminal: use --login with bash
    
    For bash, we can use a login shell to ensure we get a bit more state
    applied on the host.
    
    Related to #590

 src/plugins/terminal/gb-terminal-view.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
---
diff --git a/src/plugins/terminal/gb-terminal-view.c b/src/plugins/terminal/gb-terminal-view.c
index 544c58231..5b2b27eb1 100644
--- a/src/plugins/terminal/gb-terminal-view.c
+++ b/src/plugins/terminal/gb-terminal-view.c
@@ -53,6 +53,31 @@ static void gb_terminal_view_connect_terminal (GbTerminalView *self,
 static void gb_terminal_respawn               (GbTerminalView *self,
                                                VteTerminal    *terminal);
 
+static gboolean
+shell_supports_login (const gchar *shell)
+{
+  g_autofree gchar *name = NULL;
+
+  /* Shells that support --login */
+  static const gchar *supported[] = {
+    "bash",
+  };
+
+  if (shell == NULL)
+    return FALSE;
+
+  if (!(name = g_path_get_basename (shell)))
+    return FALSE;
+
+  for (guint i = 0; i < G_N_ELEMENTS (supported); i++)
+    {
+      if (g_str_equal (name, supported[i]))
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 gb_terminal_view_wait_cb (GObject      *object,
                           GAsyncResult *result,
@@ -263,6 +288,8 @@ gb_terminal_respawn (GbTerminalView *self,
   ide_subprocess_launcher_set_run_on_host (launcher, self->run_on_host);
   ide_subprocess_launcher_set_clear_env (launcher, FALSE);
   ide_subprocess_launcher_push_argv (launcher, shell);
+  if (shell_supports_login (shell))
+    ide_subprocess_launcher_push_argv (launcher, "--login");
   ide_subprocess_launcher_take_stdin_fd (launcher, tty_fd);
   ide_subprocess_launcher_take_stdout_fd (launcher, stdout_fd);
   ide_subprocess_launcher_take_stderr_fd (launcher, stderr_fd);


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