chiark / gitweb /
pager: support SYSTEMD_LESS environment variable
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 12 Feb 2014 02:30:10 +0000 (03:30 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 12 Feb 2014 06:10:31 +0000 (01:10 -0500)
This allows customization of the arguments used by less. The main
motivation is that some folks might not like having --no-init on every
invocation of less.

man/journalctl.xml
man/localectl.xml
man/loginctl.xml
man/machinectl.xml
man/systemctl.xml
man/systemd-analyze.xml
man/timedatectl.xml
src/shared/pager.c

index 3b05e80fc118d3d8dff1d721dab64035109f62a9..18a1b9ef2df70089401e9104b8ad8d02c3c4caf8 100644 (file)
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+                               <term><varname>$SYSTEMD_LESS</varname></term>
+                               <listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+                               default options passed to <literal>less</literal>
+                               (<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
index 0950cce97d26ab87f7798e2321be1a6496384962..238757c2e581752e25688edb816f16f437b9162f 100644 (file)
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+                               <term><varname>$SYSTEMD_LESS</varname></term>
+                               <listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+                               default options passed to <literal>less</literal>
+                               (<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
index 13105d4dcda716c10312db886c01f07dde6d865b..ede869f39487777499ca11d90f50d9130e753d53 100644 (file)
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+                               <term><varname>$SYSTEMD_LESS</varname></term>
+                               <listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+                               default options passed to <literal>less</literal>
+                               (<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
index cabdbac96290979627becaf385280bd9ab1b1260..2e7fa3bf8d4892e537e401d087d51a0fb1429b3c 100644 (file)
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+                               <term><varname>$SYSTEMD_LESS</varname></term>
+                               <listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+                               default options passed to <literal>less</literal>
+                               (<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
index ed1bf4813ae90376eff9c8f42827ac979a877626..1b0f8e5e2d48a69125f92d07a291232778ecc6e3 100644 (file)
@@ -1479,6 +1479,10 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           equivalent to passing
           <option>--no-pager</option>.</para>
         </listitem>
+       <term><varname>$SYSTEMD_LESS</varname></term>
+       <listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+       default options passed to <literal>less</literal>
+       (<literal>FRSXMK</literal>).</para></listitem> 
       </varlistentry>
     </variablelist>
   </refsect1>
index cbf59e0a1a84c77d6a44ceb55f84b74def87aae0..54479e4876ac89f63299e643fff091756f1ced5a 100644 (file)
@@ -335,6 +335,10 @@ $ eog targets.svg</programlisting>
                                         equivalent to passing
                                         <option>--no-pager</option>.</para>
                                 </listitem>
+                               <term><varname>$SYSTEMD_LESS</varname></term>
+                               <listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+                               default options passed to <literal>less</literal>
+                               (<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
index beda30485465c32b7ae97d3d16525f357679438c..be66993e15f5ff7d9cec5152302c9b4218e811f3 100644 (file)
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+                               <term><varname>$SYSTEMD_LESS</varname></term>
+                               <listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+                               default options passed to <literal>less</literal>
+                               (<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
index 72a29f22855ea569a4bbdc8a713ec36a63da07ae..55b13d6ff63ecbf80198b5d9144c12fa5474320d 100644 (file)
@@ -84,14 +84,17 @@ int pager_open(bool jump_to_end) {
 
         /* In the child start the pager */
         if (pager_pid == 0) {
+                const char* less_opts;
 
                 dup2(fd[0], STDIN_FILENO);
                 close_pipe(fd);
 
+                less_opts = getenv("SYSTEMD_LESS");
+                if (!less_opts)
+                        less_opts = "FRSXMK";
                 if (jump_to_end)
-                        setenv("LESS", "FRSXMK+G", 1);
-                else
-                        setenv("LESS", "FRSXMK", 1);
+                        less_opts = strappenda(less_opts, " +G");
+                setenv("LESS", less_opts, 1);
 
                 /* Make sure the pager goes away when the parent dies */
                 if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)