summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/more/more.131
-rw-r--r--usr.bin/more/more.c38
-rw-r--r--usr.bin/more/more.help2
3 files changed, 59 insertions, 12 deletions
diff --git a/usr.bin/more/more.1 b/usr.bin/more/more.1
index 044960b6ff7..8d31cb858a7 100644
--- a/usr.bin/more/more.1
+++ b/usr.bin/more/more.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: more.1,v 1.4 1996/09/28 22:20:48 etheisen Exp $
+.\" $OpenBSD: more.1,v 1.5 1996/10/14 09:00:58 etheisen Exp $
.\" Copyright (c) 1980 The Regents of the University of California.
.\" All rights reserved.
.\"
@@ -32,7 +32,7 @@
.\"
.\" @(#)more.1 6.6 (Berkeley) 4/18/91
.\"
-.TH MORE 1 "April 18, 1991"
+.TH MORE 1 "October 14, 1996"
.UC 4
.SH NAME
more, page \- file perusal filter for crt viewing
@@ -195,6 +195,25 @@ or
.I .profile
file.
.PP
+.I More
+looks in the environment variable
+.I EDITOR
+to determine which editor the
+.I v
+command invokes.
+If the editor specified is
+.I vi
+or
+.I ex
+it will start at the current
+.I more
+line number.
+If no
+.I EDITOR
+environment variable is specified the default
+.I vi
+editor will be used.
+.PP
If
.I more
is reading from a file, rather than a pipe, then a percentage is displayed
@@ -245,9 +264,13 @@ Exit from
Display the current line number.
.PP
.IP v
-Start up the editor
+Starts the editor at the current line number if editor is
.I vi
-at the current line.
+or
+.I ex.
+The environment variable
+.I EDITOR
+affects this command according to the rules outlined above.
.PP
.IP h
Help command; give a description of all the
diff --git a/usr.bin/more/more.c b/usr.bin/more/more.c
index a853147bc03..42468e47d3e 100644
--- a/usr.bin/more/more.c
+++ b/usr.bin/more/more.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: more.c,v 1.4 1996/10/14 03:54:59 etheisen Exp $ */
+/* $OpenBSD: more.c,v 1.5 1996/10/14 09:01:01 etheisen Exp $ */
/*-
* Copyright (c) 1980 The Regents of the University of California.
* All rights reserved.
@@ -977,6 +977,9 @@ register FILE *f;
FILE *helpf;
int done;
char comchar, cmdbuf[80], *p;
+ char option[8];
+ char *EDITOR;
+ char *editor;
#define ret(val) retval=val;done++;break
@@ -1162,14 +1165,35 @@ register FILE *f;
fclose (helpf);
prompt (filename);
break;
+ /* Run Editor */
case 'v': /* This case should go right before default */
if (!no_intty) {
kill_line ();
- cmdbuf[0] = '+';
+ strcpy(cmdbuf, "-c");
scanstr (Currline - dlines < 0 ? 0
- : Currline - (dlines + 1) / 2, &cmdbuf[1]);
- pr ("vi "); pr (cmdbuf); putchar (' '); pr (fnames[fnum]);
- execute (filename, _PATH_VI, "vi", cmdbuf, fnames[fnum], 0);
+ : Currline - (dlines + 1) / 2, option);
+
+ /* POSIX.2 more EDITOR env. var. behavior */
+ if ((EDITOR = getenv("EDITOR")) != NULL) {
+
+ /* Need to look for vi or ex as
+ * we need to tell them the current
+ * line number
+ */
+ if ((editor = strrchr(EDITOR, '/')) == NULL)
+ editor = EDITOR;
+ else
+ editor++;
+ if ((strcmp(editor, "vi") == 0) ||
+ (strcmp(editor, "ex") == 0))
+ execute (filename, EDITOR, EDITOR, cmdbuf, option, fnames[fnum], 0);
+ else /* must be some other editor */
+ execute (filename, EDITOR, EDITOR, fnames[fnum], 0);
+ }
+ else { /* default editor */
+ execute (filename, _PATH_VI, _PATH_VI, cmdbuf, option, fnames[fnum], 0);
+ }
+
break;
}
default:
@@ -1410,7 +1434,7 @@ va_dcl
open("/dev/tty", 0);
}
va_start(argp);
- execv (cmd, argp);
+ execvp (cmd, argp);
write (2, "exec failed\n", 12);
exit (1);
va_end(argp); /* balance {}'s for some UNIX's */
@@ -1428,7 +1452,7 @@ va_dcl
} else
write(2, "can't fork\n", 11);
set_tty ();
- pr ("------------------------\n");
+ /* pr ("------------------------\n"); */
prompt (filename);
}
/*
diff --git a/usr.bin/more/more.help b/usr.bin/more/more.help
index ef529e2d5b6..f67805a1ff0 100644
--- a/usr.bin/more/more.help
+++ b/usr.bin/more/more.help
@@ -15,7 +15,7 @@ b or ctrl-B Skip backwards k screenfuls of text [1]
/<regular expression> Search for kth occurrence of regular expression [1]
n Search for kth occurrence of last r.e [1]
!<cmd> or :!<cmd> Execute <cmd> in a subshell
-v Start up $EDITOR or /usr/bin/vi at current line
+v Starts $EDITOR or /usr/bin/vi at current line
ctrl-L Redraw screen
:n Go to kth next file [1]
:p Go to kth previous file [1]