gst-inspect: Don't setup pager too early
authorSeungha Yang <seungha.yang@navercorp.com>
Thu, 17 Jan 2019 02:22:27 +0000 (11:22 +0900)
committerSeungha Yang <seungha.yang@navercorp.com>
Thu, 17 Jan 2019 11:51:54 +0000 (20:51 +0900)
Setup it only if we have something to print out about inspected results.
Otherwise, gst_tools_print_version() output will be redirected to pager and also
exit immediately without waiting child process.

tools/gst-inspect.c

index e1e5693..c581d7f 100644 (file)
@@ -2006,27 +2006,6 @@ main (int argc, char *argv[])
   gst_init (&argc, &argv);
 #endif
 
-  no_colors = g_getenv ("GST_INSPECT_NO_COLORS");
-  /* We only support truecolor */
-  colored_output &= (no_colors == NULL);
-
-#ifdef G_OS_UNIX
-  if (isatty (STDOUT_FILENO)) {
-    if (redirect_stdout ())
-      loop = g_main_loop_new (NULL, FALSE);
-  } else {
-    colored_output = FALSE;
-  }
-#elif defined(G_OS_WIN32)
-  {
-    gint fd = _fileno (stdout);
-    /* On Windows 10, g_log_writer_supports_color will also setup the console
-     * so that it correctly interprets ANSI VT sequences if it's supported */
-    if (!_isatty (fd) || !g_log_writer_supports_color (fd))
-      colored_output = FALSE;
-  }
-#endif
-
   gst_tools_print_version ();
 
   if (print_all && argc > 1) {
@@ -2077,6 +2056,27 @@ main (int argc, char *argv[])
     return exit_code;
   }
 
+  no_colors = g_getenv ("GST_INSPECT_NO_COLORS");
+  /* We only support truecolor */
+  colored_output &= (no_colors == NULL);
+
+#ifdef G_OS_UNIX
+  if (isatty (STDOUT_FILENO)) {
+    if (redirect_stdout ())
+      loop = g_main_loop_new (NULL, FALSE);
+  } else {
+    colored_output = FALSE;
+  }
+#elif defined(G_OS_WIN32)
+  {
+    gint fd = _fileno (stdout);
+    /* On Windows 10, g_log_writer_supports_color will also setup the console
+     * so that it correctly interprets ANSI VT sequences if it's supported */
+    if (!_isatty (fd) || !g_log_writer_supports_color (fd))
+      colored_output = FALSE;
+  }
+#endif
+
   /* if no arguments, print out list of elements */
   if (uri_handlers) {
     print_all_uri_handlers ();