diff options
author | peter <peter@FreeBSD.org> | 1995-10-04 09:33:39 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1995-10-04 09:33:39 +0000 |
commit | 621b13f3391aea844d9ca5886b265377312b1bda (patch) | |
tree | 8f2d9abf8c1a5c61d721961ac5c782809288f4a0 /usr.bin/more/command.c | |
parent | 9e94a3c011ae7a88b9bfff9d3363b58499095f36 (diff) | |
download | FreeBSD-src-621b13f3391aea844d9ca5886b265377312b1bda.zip FreeBSD-src-621b13f3391aea844d9ca5886b265377312b1bda.tar.gz |
Make more pass +linenumber to vi (and emacs), even if $EDITOR is used.
Closes PR#441, but with a more generic method.
Diffstat (limited to 'usr.bin/more/command.c')
-rw-r--r-- | usr.bin/more/command.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/more/command.c b/usr.bin/more/command.c index 1585245..b26fa22 100644 --- a/usr.bin/more/command.c +++ b/usr.bin/more/command.c @@ -39,6 +39,7 @@ static char sccsid[] = "@(#)command.c 8.1 (Berkeley) 6/6/93"; #include <sys/param.h> #include <stdio.h> #include <ctype.h> +#include <string.h> #include <less.h> #include "pathnames.h" @@ -594,16 +595,25 @@ editfile() extern char *current_file; static int dolinenumber; static char *editor; + char *base; int c; char buf[MAXPATHLEN * 2 + 20], *getenv(); if (editor == NULL) { editor = getenv("EDITOR"); - /* pass the line number to vi */ - if (editor == NULL || *editor == '\0') { + + /* default editor is vi */ + if (editor == NULL || *editor == '\0') editor = _PATH_VI; + + /* check last component in case of full path */ + base = strrchr(editor, '/'); + if (!base) + base = editor; + + /* emacs also accepts vi-style +nnnn */ + if (strcmp(base, "vi") == 0 || strcmp(base, "emacs") == 0) dolinenumber = 1; - } else dolinenumber = 0; } |