Whoops! Forgot to include Mr. Sobray's more command in the last set
of commits. Submitted by: Daniel C. Sobral <dcs@newsguy.com>
This commit is contained in:
parent
5b3c6cedf5
commit
ae84df99c4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43491
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: commands.c,v 1.8 1999/01/09 02:34:48 msmith Exp $
|
||||
* $Id: commands.c,v 1.9 1999/01/11 06:41:31 msmith Exp $
|
||||
*/
|
||||
|
||||
#include <stand.h>
|
||||
@ -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.
|
||||
@ -383,6 +384,50 @@ command_read(int argc, char *argv[])
|
||||
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
|
||||
*/
|
||||
|
@ -84,6 +84,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
|
||||
|
||||
@ -241,7 +250,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.
|
||||
|
Loading…
Reference in New Issue
Block a user