From owner-freebsd-bugs Thu Jan 28 07:40:08 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA02033 for freebsd-bugs-outgoing; Thu, 28 Jan 1999 07:40:08 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA01997 for ; Thu, 28 Jan 1999 07:40:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.2/8.9.2) id HAA65634; Thu, 28 Jan 1999 07:40:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA01792 for ; Thu, 28 Jan 1999 07:37:03 -0800 (PST) (envelope-from dcs@newsguy.com) Received: from daniel.sobral by peach.ocn.ne.jp (8.9.1a/OCN) id AAA12367; Fri, 29 Jan 1999 00:36:59 +0900 (JST) Received: (from root@localhost) by daniel.sobral (8.9.1/8.9.2) id AAA00399; Fri, 29 Jan 1999 00:36:27 +0900 (JST) (envelope-from root) Message-Id: <199901281536.AAA00399@daniel.sobral> Date: Fri, 29 Jan 1999 00:36:27 +0900 (JST) From: dcs@newsguy.com Reply-To: dcs@newsguy.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/9753: Loader needs a pager Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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 [ ...] + + 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 + include [ ...] The entire contents of 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