Bug 31420

Summary: nvi ignores -c flag when creating a new file
Product: Base System Reporter: sjhgnats <sjhgnats>
Component: binAssignee: Mike Heffner <mikeh>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description sjhgnats 2001-10-22 01:10:01 UTC
	"nvi -c "set someoption=xx" newfile" ignores the -c flag if newfile doesn't already exist.

Fix: This simple patch seems to fix the problem. I am not very familiar with all the inner workings of nvi, so it may break other things. Can someone clarify if this is true/false?

Working dir for this patch is: /usr/src/contrib/nvi
How-To-Repeat: 	To test:

	nvi -c "set wraplen=10"
	<type random crap> - it doesn't wrap, and no errors are given. -c is silently ignored.
	
	Or:
	nvi -c "set wraplen=10" foobar
	<type random crap> - again, -c is silently ignored

	touch foobar
	nvi -c "set wraplen=10" foobar
	<type random crap> - it now wraps.
Comment 1 Mike Heffner freebsd_committer freebsd_triage 2001-10-22 02:08:38 UTC
State Changed
From-To: open->feedback

Can you test whether the similar patch in bin/21654 works?
Comment 2 mheffner 2001-10-22 02:21:16 UTC
On 22-Oct-2001 mikeh@FreeBSD.ORG wrote:
| Synopsis: nvi ignores -c flag when creating a new file
| 
| State-Changed-From-To: open->feedback
| State-Changed-By: mikeh
| State-Changed-When: Sun Oct 21 18:08:38 PDT 2001
| State-Changed-Why: 
| Can you test whether the similar patch in bin/21654 works?
| 

Actually nevermind, bin/21654 just makes it output a warning when used with
a new file.

Mike

-- 
  Mike Heffner     <mheffner@[acm.]vt.edu>
  Blacksburg, VA       <mikeh@FreeBSD.org>
Comment 3 Mike Heffner freebsd_committer freebsd_triage 2001-10-22 02:25:27 UTC
State Changed
From-To: feedback->open

bin/21654 just outputs a warning 


Comment 4 Mike Heffner freebsd_committer freebsd_triage 2001-10-22 02:25:27 UTC
Responsible Changed
From-To: freebsd-bugs->mikeh

I'll take a look at this.
Comment 5 Mike Heffner freebsd_committer freebsd_triage 2001-11-07 06:39:38 UTC
State Changed
From-To: open->closed

From Keith Bostic: 

I believe that nvi follows historic practice -- there's a comment 
in the nvi sources (common/exf.c) that explains this: 

/* 
* Historically, initial commands (the -c option) weren't executed 
* until a file was loaded, e.g. "vi +10 nofile", followed by an 
* :edit or :tag command, would execute the +10 on the file loaded 
* by the subsequent command, (assuming that it existed).  This 
* applied as well to files loaded using the tag commands, and we 
* follow that historic practice.  Also, all initial commands were 
* ex commands and were always executed on the last line of the file. 

I suspect the reasoning is that you can load the wrong file, and 
then fix it, and still get your initial command.  So: 

% vi '?bostic' /etc/Passwd 
:e /etc/passwd 

will do the right thing -- when you switch to the file you really 
wanted, the command is then executed.