Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Feb 1998 15:55:56 -0500 (EST)
From:      meuston@jmrodgers.com
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/5838: Make more(1) use LINES= and COLUMNS= environment variables.
Message-ID:  <199802242055.PAA01663@mail.jmrodgers.com>

next in thread | raw e-mail | index | archive | help

>Number:         5838
>Category:       bin
>Synopsis:       Make more(1) use LINES= and COLUMNS= environment variables.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 24 13:00:01 PST 1998
>Last-Modified:
>Originator:     Max Euston
>Organization:
>Release:        FreeBSD 2.2.5-STABLE i386
>Environment:

FreeBSD mail.jmrodgers.com 2.2.5-STABLE FreeBSD 2.2.5-STABLE #0: Tue Feb 24 08:33:10 EST 1998     root@:/var/src/sys/compile/GATEWAY  i386

>Description:

3 problems:

	- more(1) does not work with arbitrary screen sizes (like in a
	  telnet session from Win-95) and has no way to specify the screen
	  size without generating a new terminfo definition.

	- the '-#' option was meant to do this, but has not worked as far
	  back as I can check in the revision history.  (as per the
	  discussions on "hackers", I have removed this option).

	- when displaying h)elp, more(1) does not pause before redrawing
	  the screen (unless you have MORE=-e in your environment).

>How-To-Repeat:

	Run more(1) from a telnet session with a non-standard screen size.

>Fix:

	(This is my first PR, feel free to suggest improvments/corrections).

	Should apply to RELENG_2_2 and HEAD?

diff -ru /usr/src/usr.bin/more/help.c /usr/local/src/usr.bin/more/help.c
--- /usr/src/usr.bin/more/help.c	Fri May 27 08:30:46 1994
+++ /usr/local/src/usr.bin/more/help.c	Wed Feb 18 10:27:41 1998
@@ -40,10 +40,12 @@
 #include <less.h>
 #include "pathnames.h"
 
+extern int top_scroll;
+
 help()
 {
 	char cmd[MAXPATHLEN + 20];
 
-	(void)sprintf(cmd, "-more %s", _PATH_HELPFILE);
+	(void)sprintf(cmd, "-more -e%c %s", top_scroll ? 'c' : ' ', _PATH_HELPFILE);
 	lsystem(cmd);
 }
diff -ru /usr/src/usr.bin/more/more.1 /usr/local/src/usr.bin/more/more.1
--- /usr/src/usr.bin/more/more.1	Wed Jul 30 02:43:57 1997
+++ /usr/local/src/usr.bin/more/more.1	Tue Feb 24 14:41:27 1998
@@ -40,11 +40,10 @@
 .Nd file perusal filter for crt viewing
 .Sh SYNOPSIS
 .Nm
-.Op Fl ceinus
+.Op Fl ceinsu
 .Op Fl t Ar tag
 .Op Fl x Ar tabs
 .Op Fl / Ar pattern
-.Op Fl #
 .Op Ar
 .Sh DESCRIPTION
 .Nm More
@@ -278,8 +277,14 @@
 .It Ev MORE
 This variable may be set with favored options to
 .Nm more .
+.It Ev COLUMNS
+The number of columns on the screen.  This value overrides any system
+or terminal specific values.
 .It Ev EDITOR
 Specify default editor.
+.It Ev LINES
+The number of rows on the screen.  This value overrides any system
+or terminal specific values.
 .It Ev SHELL
 Current shell in use (normally set by the shell at login time).
 .It Ev TERM
diff -ru /usr/src/usr.bin/more/option.c /usr/local/src/usr.bin/more/option.c
--- /usr/src/usr.bin/more/option.c	Mon Sep 15 05:20:52 1997
+++ /usr/local/src/usr.bin/more/option.c	Tue Feb 24 14:45:27 1998
@@ -54,7 +54,6 @@
 int tagoption;
 
 char *firstsearch;
-extern int sc_height;
 
 static void usage __P((void));
 
@@ -75,23 +74,8 @@
 			(*a)[0] = '-';
 
 	optind = 1;		/* called twice, re-init getopt. */
-	while ((ch = getopt(argc, argv, "0123456789/:ceinst:ux:f")) != -1)
+	while ((ch = getopt(argc, argv, "/:ceinst:ux:f")) != -1)
 		switch((char)ch) {
-		case '0': case '1': case '2': case '3': case '4':
-		case '5': case '6': case '7': case '8': case '9':
-			/*
-			 * kludge: more was originally designed to take
-			 * a number after a dash.
-			 */
-			if (!sc_window_set) {
-				p = argv[optind - 1];
-				if (p[0] == '-' && p[1] == ch && !p[2])
-					sc_height = atoi(++p);
-				else
-					sc_height = atoi(argv[optind] + 1);
-				sc_window_set = 1;
-			}
-			break;
 		case '/':
 			firstsearch = optarg;
 			break;
@@ -135,6 +119,6 @@
 usage()
 {
 	fprintf(stderr,
-	"usage: more [-ceinus] [-t tag] [-x tabs] [-/ pattern] [-#] [file ...]\n");
+	"usage: more [-ceinsu] [-t tag] [-x tabs] [-/ pattern] [file ...]\n");
 	exit(1);
 }
diff -ru /usr/src/usr.bin/more/screen.c /usr/local/src/usr.bin/more/screen.c
--- /usr/src/usr.bin/more/screen.c	Sat Aug  5 17:25:28 1995
+++ /usr/local/src/usr.bin/more/screen.c	Mon Feb 23 16:54:19 1998
@@ -239,6 +239,7 @@
 	char termbuf[2048];
 	char *sp;
 	char *term;
+	char *estr;
 	int hard;
 #ifdef TIOCGWINSZ
 	struct winsize w;
@@ -265,14 +266,22 @@
 #ifdef TIOCGWINSZ
 	if (ioctl(2, TIOCGWINSZ, &w) == 0 && w.ws_row > 0)
 		sc_height = w.ws_row;
+	else
 #else
 #ifdef WIOCGETD
 	if (ioctl(2, WIOCGETD, &w) == 0 && w.uw_height > 0)
 		sc_height = w.uw_height/w.uw_vs;
+	else
 #endif
 #endif
-	else
 		sc_height = tgetnum("li");
+
+	/*
+	 * Allow the user to override the screen height
+	 */
+ 	if ((estr = getenv("LINES")) != NULL)
+ 		sc_height = atoi(estr);
+
 	hard = (sc_height < 0 || tgetflag("hc"));
 	if (hard) {
 		/* Oh no, this is a hardcopy terminal. */
@@ -290,6 +299,13 @@
 #endif
 #endif
  		sc_width = tgetnum("co");
+
+	/*
+	 * Allow the user to override the screen width
+	 */
+ 	if ((estr = getenv("COLUMNS")) != NULL)
+ 		sc_width = atoi(estr);
+
  	if (sc_width < 0)
   		sc_width = 80;
 

--------------- end
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199802242055.PAA01663>