[gnome-builder/wip/gtk4-port: 871/1774] libide/io: macOS support for guessing user shell




commit 81f30d3c3685ea7bf2f2177e901afaf676d1e7c3
Author: Christian Hergert <christian hergert me>
Date:   Thu May 5 10:34:04 2022 -0700

    libide/io: macOS support for guessing user shell
    
    We can get the results for the user shell using dscacheutil as getent does
    not work on macOS.

 src/libide/io/ide-shell.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/io/ide-shell.c b/src/libide/io/ide-shell.c
index d7625f031..8e69d5ec3 100644
--- a/src/libide/io/ide-shell.c
+++ b/src/libide/io/ide-shell.c
@@ -78,6 +78,8 @@ ide_guess_shell_communicate_cb (GObject      *object,
       if (stdout_buf[0] == '/')
         user_shell = g_steal_pointer (&stdout_buf);
     }
+
+  g_debug ("Guessed user shell as \"%s\"", user_shell);
 }
 
 void
@@ -88,10 +90,14 @@ _ide_guess_shell (void)
   g_autofree gchar *command = NULL;
   g_autoptr(GError) error = NULL;
   g_auto(GStrv) argv = NULL;
-  g_autofree gchar *shell = NULL;
 
+#ifdef __APPLE__
+  command = g_strdup_printf ("sh -c 'dscacheutil -q user -a name %s | grep ^shell: | cut -f 2 -d \" \"'",
+                             g_get_user_name ());
+#else
   command = g_strdup_printf ("sh -c 'getent passwd %s | head -n1 | cut -f 7 -d :'",
                              g_get_user_name ());
+#endif
 
   if (!g_shell_parse_argv (command, NULL, &argv, &error))
     {


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