gst-inspect: Allow overriding DEFAULT_LESS_OPTS with GST_LESS
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>
Fri, 19 Mar 2021 12:46:13 +0000 (13:46 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 7 Apr 2021 22:01:14 +0000 (22:01 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/777>

tools/gst-inspect-1.0.1
tools/gst-inspect.c

index 6cd5c66..6299f4c 100644 (file)
@@ -81,6 +81,17 @@ Enable printout of errors while loading \fIGStreamer\fP plugins
 .B  \-\-gst\-plugin\-path=PATH
 Add directories separated with ':' to the plugin search path
 .
+.SH "ENVIRONMENT VARIABLES"
+.l
+\fIgst\-inspect\-1.0\fP reads the following environment variables, in addition
+to the generic \fIGStreamer\fP environment variables also described in
+.BR gst\-launch\-1.0 (1):
+.TP 8
+.B GST_LESS
+Override the options passed to \fIless\fR (by default "RXF").
+.br
+See \fBless\fR(1) for more information.
+.
 .SH "SEE ALSO"
 .BR gst\-launch\-1.0 (1),
 .BR gst\-typefind\-1.0 (1)
index e0d5a41..3791ec1 100644 (file)
@@ -45,6 +45,9 @@
 /* "R" : support color
  * "X" : do not clear the screen when leaving the pager
  * "F" : skip the pager if content fit into the screen
+ *
+ * Don't forget to update the manpage gst-inspect-1.0.1
+ * after changing this default.
  */
 #define DEFAULT_LESS_OPTS "RXF"
 
@@ -1949,7 +1952,7 @@ redirect_stdout (void)
 {
   GError *error = NULL;
   gchar **argv;
-  const gchar *pager;
+  const gchar *pager, *less;
   gint stdin_fd;
   gchar **envp;
 
@@ -1959,8 +1962,12 @@ redirect_stdout (void)
 
   argv = g_strsplit (pager, " ", 0);
 
+  less = g_getenv ("GST_LESS");
+  if (less == NULL)
+    less = DEFAULT_LESS_OPTS;
+
   envp = g_get_environ ();
-  envp = g_environ_setenv (envp, "LESS", DEFAULT_LESS_OPTS, TRUE);
+  envp = g_environ_setenv (envp, "LESS", less, TRUE);
 
   if (!g_spawn_async_with_pipes (NULL, argv, envp,
           G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,