Date: Fri, 29 Jan 1999 00:36:27 +0900 (JST) From: dcs@newsguy.com To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/9753: Loader needs a pager Message-ID: <199901281536.AAA00399@daniel.sobral>
index | next in thread | raw e-mail
>Number: 9753
>Category: bin
>Synopsis: Loader needs a pager
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Jan 28 07:40:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator: Daniel C. Sobral
>Release: FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:
Current as of Jan 24.
>Description:
Jordan said he was putting cat/more into loader. Well, I'm tired
waiting... :-) Here is the more. He can do the cat.
>How-To-Repeat:
cat file
more file
>Fix:
Apply the following fix. Notice I changed something in libstand.
It makes things more useful, IMHO, but YMMV. You can safely remove it,
which will just worsen the looks... :-)
--- src/lib/libstand/pager.c.orig Thu Jan 28 23:57:45 1999
+++ src/lib/libstand/pager.c Thu Jan 28 23:58:50 1999
@@ -139,7 +139,6 @@
return(-1);
}
- pager_open();
for (;;) {
hmuch = read(fd, buf, sizeof(buf) - 1);
if (hmuch == -1) {
@@ -156,7 +155,6 @@
break;
}
}
- pager_close();
close(fd);
return(result);
}
--- src/sys/boot/common/commands.c 1999/01/28 14:24:20 1.3
+++ src/sys/boot/common/commands.c 1999/01/28 15:17:56
@@ -35,6 +35,7 @@
char *command_errmsg;
char command_errbuf[256]; /* XXX should have procedural interface for setting, size limit? */
+static int page_file(char *filename);
/*
* Help is read from a formatted text file.
@@ -382,6 +383,50 @@
setenv(name, buf, 1);
return(CMD_OK);
}
+
+/*
+ * File pager
+ */
+COMMAND_SET(more, "more", "show contents of a file", command_more);
+
+static int
+command_more(int argc, char *argv[])
+{
+ int i;
+ int res;
+ char line[80];
+
+ res=0;
+ pager_open();
+ for (i = 1; (i < argc) && (res == 0); i++) {
+ sprintf(line, "*** FILE %s BEGIN ***\n", argv[i]);
+ pager_output(line);
+ res = page_file(argv[i]);
+ if (!res) {
+ sprintf(line, "*** FILE %s END ***\n", argv[i]);
+ pager_output(line);
+ }
+ }
+ pager_close();
+
+ if (res == 0)
+ return CMD_OK;
+ else
+ return CMD_ERROR;
+}
+
+static int
+page_file(char *filename)
+{
+ int result;
+
+ result = pager_file(filename);
+
+ if (result == -1)
+ sprintf(command_errbuf, "error showing %s", filename);
+
+ return result;
+}
/*
* List all disk-like devices
--- src/sys/boot/common/help.common 1999/01/28 14:42:49 1.3
+++ src/sys/boot/common/help.common 1999/01/28 14:43:05
@@ -85,6 +85,15 @@
List loaded modules. If [-v] is specified, print more details.
################################################################################
+# Tmore DPage files
+
+ more <filename> [<filename> ...]
+
+ Show contents of text files. When displaying the contents of more,
+ than one file, if the user elects to quit displaying a file, the
+ remaining files will not be shown.
+
+################################################################################
# Tpnpscan DScan for PnP devices
pnpscan [-v]
@@ -233,7 +242,7 @@
################################################################################
# Tinclude DRead commands from a script file
- include <filename>
+ include <filename> [<filename> ...]
The entire contents of <filename> are read into memory before executing
commands, so it is safe to source a file from removable media.
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901281536.AAA00399>
