[console] application: Don't split vte_get_user_shell() into arguments



commit 9d3a8ed5565f9c0a96de85e9995f99698cd291e8
Author: Simon McVittie <smcv debian org>
Date:   Sat Apr 9 17:03:11 2022 +0100

    application: Don't split vte_get_user_shell() into arguments
    
    The pw_shell member of struct passwd is a single executable, not a
    shell one-liner, so it should be used as argv[0] rather than parsing it
    into one or more arguments. This is consistent with how xterm and
    gnome-terminal use it.
    
    Signed-off-by: Simon McVittie <smcv debian org>

 src/kgx-application.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/kgx-application.c b/src/kgx-application.c
index fc4bae4..2d3f70a 100644
--- a/src/kgx-application.c
+++ b/src/kgx-application.c
@@ -1160,20 +1160,25 @@ kgx_application_add_terminal (KgxApplication *self,
   GtkWidget *tab;
   KgxPages *pages;
 
-  g_shell_parse_argv (command ? command : user_shell, NULL, &shell, &error);
+  if (command != NULL) {
+    g_shell_parse_argv (command, NULL, &shell, &error);
 
-  if (error) {
-    g_warning ("Failed to parse ā€œ%sā€ as a command",
-               command ? command : user_shell);
-    shell = NULL;
-    g_clear_error (&error);
+    if (error) {
+      g_warning ("Failed to parse ā€œ%sā€ as a command", command);
+      shell = NULL;
+      g_clear_error (&error);
+    }
   }
 
-  if (G_LIKELY (command == NULL)) {
+  if (G_LIKELY (shell == NULL)) {
     custom_shell = g_settings_get_strv (self->settings, "shell");
 
     if (g_strv_length (custom_shell) > 0) {
       shell = g_steal_pointer (&custom_shell);
+    } else if (user_shell != NULL) {
+      shell = g_new0 (char *, 2);
+      shell[0] = g_steal_pointer (&user_shell);
+      shell[1] = NULL;
     }
   }
 


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