| Summary: | Re: nvi's -c flag does no do what it is documented to do. (it does nothing) | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Seth Kingsley <sethk> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 1.0-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
Responsible Changed From-To: gnats-admin->freebsd-bugs misfiled State Changed From-To: open->closed Superseded by bin/31420. |
It looks like not executing commands specified with the -c or + option is part of Nvi's compatiblity with traditional Vi. Also, using :r on a new file changes the filename of the current file to the file you just read from. This means that using vi -c'r /etc/motd' is effectively the same as just editing /etc/motd. The following patches complain when using the -c option without an initial filename: Index: common/exf.c =================================================================== RCS file: /ncvs/src/contrib/nvi/common/exf.c,v retrieving revision 1.3 diff -u -r1.3 exf.c --- common/exf.c 2000/01/10 09:17:46 1.3 +++ common/exf.c 2000/09/30 02:05:09 @@ -546,14 +546,17 @@ */ nb = 0; gp = sp->gp; - if (gp->c_option != NULL && !F_ISSET(sp->frp, FR_NEWFILE)) { + if (gp->c_option != NULL) { if (db_last(sp, &sp->lno)) return; if (sp->lno == 0) { sp->lno = 1; sp->cno = 0; } - if (ex_run_str(sp, + if (F_ISSET(sp->frp, FR_NEWFILE)) + msgq_str(sp, M_ERR, sp->frp->name, + "318|%s: Warning: +cmd ignored for new file"); + else if (ex_run_str(sp, "-c option", gp->c_option, strlen(gp->c_option), 1, 1)) return; gp->c_option = NULL; Index: docs/USD.doc/vi.man/vi.1 =================================================================== RCS file: /ncvs/src/contrib/nvi/docs/USD.doc/vi.man/vi.1,v retrieving revision 1.4 diff -u -r1.4 vi.1 --- docs/USD.doc/vi.man/vi.1 1997/09/18 06:49:40 1.4 +++ docs/USD.doc/vi.man/vi.1 2000/09/30 02:31:46 @@ -107,7 +107,8 @@ is not limited to positioning commands. This is the POSIX 1003.2 interface for the historic ``+cmd'' syntax. .I Nex/nvi -supports both the old and new syntax. +supports both the old and new syntax. If no file is specified, this +option is ignored. .TP .B \-e Start editing in ex mode, as if the command name were -- || Seth Kingsley || BSDi/Open Source Division || sethk@osd.bsdi.com || || The only thing missing from the emacs OS is a good text editor ||