[gnome-builder] main: use SHLVL=0 to detect we are not run from a terminal



commit d1ae171804abc2f612da4bb4a4d72525da7fe1b4
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 15 12:22:35 2019 -0700

    main: use SHLVL=0 to detect we are not run from a terminal
    
    This can allow us to disable gdb self-inspection helpers when run directly
    from gnome-shell or other desktop shells.

 src/main.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/main.c b/src/main.c
index 1412cc11e..69176aad0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -175,6 +175,15 @@ home_contains_symlink (void)
 static gboolean
 is_running_in_shell (void)
 {
+  const gchar *shlvl = g_getenv ("SHLVL");
+
+  /* GNOME Shell, among other desktop shells may set SHLVL=0 to indicate
+   * that we are not running within a shell. Use that before checking any
+   * file-descriptors since it is more reliable.
+   */
+  if (ide_str_equal0 (shlvl, "0"))
+    return FALSE;
+
   /* If stdin is not a TTY, then assume we have no access to communicate
    * with the user via console. We use stdin instead of stdout as a logging
    * system may have a PTY for stdout to get colorized output.


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