]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
more: Add MORE_SHELL_LINES environmental variable
authorcgoesche <cgoesc2@wgu.edu>
Fri, 13 Jun 2025 05:59:28 +0000 (01:59 -0400)
committerKarel Zak <kzak@redhat.com>
Tue, 24 Jun 2025 09:32:58 +0000 (11:32 +0200)
This provides an alternative way to set the number of lines per screenful, with the same
effect as the '-n' and '--lines' command line options.

[kzak@redhat.com: - use ul_strtou16()]

Addresses: #3476
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/more.1.adoc
text-utils/more.c

index d40b79bae39f46ac728fe1a08acc0d48e959ef72..546214e7e4842eabbd6b3ce6a4c1ad8c1eb02ecc 100644 (file)
@@ -199,7 +199,10 @@ Disable exit-on-eof (see option *-e* for more details).
 Run *more* in "secure" mode. See SECURITY for details.
 
 *PAGERSECURE*::
-Equivalent to MORESECURE. 
+Equivalent to MORESECURE.
+
+*MORE_SHELL_LINES*::
+Specify the _number_ of lines per screenful. It has the same effect as the '-n' and '--lines' options. See in OPTIONS for details. Also, note that the environment variable's value will be overridden if any of these options are set.
 
 == HISTORY
 
@@ -213,7 +216,7 @@ Modified by Geoff Peck, UCB to add underlining, single spacing.
 
 Modified by John Foderaro, UCB to add -c and MORE environment variable.
 
-Modified by Christian Goeschel Ndjomouo to add MORESECURE and PAGERSECURE environment variables, and a SECURITY section
+Modified by Christian Goeschel Ndjomouo to add MORESECURE, PAGERSECURE and MORE_SHELL_LINES environment variables, and a SECURITY section
 
 == SEE ALSO
 
index d87af4354a84167f710a8819dd4c5d33ddc3c47a..fa5513fd0d8e0eff28cd51e1def8f4023d421224 100644 (file)
@@ -42,7 +42,7 @@
  * 2010-10-21 Davidlohr Bueso <dave@gnu.org>
  *     modified mem allocation handling for util-linux
  * 2025-04-03 Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
- *     modified to add MORESECURE and PAGERSECURE environment variables
+ *     modified to add MORESECURE, PAGERSECURE and MORE_SHELL_LINES environment variables
  */
 
 #include <stdio.h>
@@ -2130,6 +2130,9 @@ int main(int argc, char **argv)
        if (getenv("MORESECURE") || getenv("PAGERSECURE"))
                ctl.is_secure = 1;
 
+       if ((s = getenv("MORE_SHELL_LINES")) && isdigit_string(s))
+               ul_strtou16(s, (uint16_t *) &ctl.lines_per_screen, 10);
+
        if ((s = getenv("MORE")) != NULL)
                env_argscan(&ctl, s);