From root@goldenterrace.com.au  Sun Oct 21 17:02:59 2001
Return-Path: <root@goldenterrace.com.au>
Received: from squishycow.goldenterrace.com.au (squishycow.goldenterrace.com.au [203.41.110.130])
	by hub.freebsd.org (Postfix) with ESMTP id B0F2837B405
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 21 Oct 2001 17:02:57 -0700 (PDT)
Received: by squishycow.goldenterrace.com.au (Postfix, from userid 0)
	id 4820219D42; Mon, 22 Oct 2001 10:02:55 +1000 (EST)
Message-Id: <20011022000255.4820219D42@squishycow.goldenterrace.com.au>
Date: Mon, 22 Oct 2001 10:02:55 +1000 (EST)
From: Steve Horan <sjhgnats@tracking.amos.net>
Reply-To: Steve Horan <sjhgnats@tracking.amos.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: nvi ignores -c flag when creating a new file
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         31420
>Category:       bin
>Synopsis:       nvi ignores -c flag when creating a new file
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mikeh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 21 17:10:01 PDT 2001
>Closed-Date:    Tue Nov 6 22:39:38 PST 2001
>Last-Modified:  Tue Nov 06 22:40:14 PST 2001
>Originator:     Steve Horan
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
n/a
>Environment:
System: FreeBSD 4.3-STABLE FreeBSD 4.3-STABLE #1: Sun Jul 22 10:59:34 EST 2001


	The sources used for nvi are the latest from 4.4-STABLE
>Description:
	"nvi -c "set someoption=xx" newfile" ignores the -c flag if newfile doesn't already exist.
>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.

>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

--- common/exf.c.orig	Mon Oct 22 09:43:36 2001
+++ common/exf.c	Mon Oct 22 09:43:04 2001
@@ -546,7 +546,7 @@
 	 */
 	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) {
>Release-Note:
>Audit-Trail:
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? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31420 
State-Changed-From-To: feedback->open 
State-Changed-By: mikeh 
State-Changed-When: Sun Oct 21 18:25:27 PDT 2001 
State-Changed-Why:  
bin/21654 just outputs a warning 


Responsible-Changed-From-To: freebsd-bugs->mikeh 
Responsible-Changed-By: mikeh 
Responsible-Changed-When: Sun Oct 21 18:25:27 PDT 2001 
Responsible-Changed-Why:  
I'll take a look at this. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31420 

From: Mike Heffner <mheffner@vt.edu>
To: mikeh@freebsd.org
Cc: sjhgnats@tracking.amos.net, freebsd-gnats-submit@freebsd.org
Subject: Re: bin/31420: nvi ignores -c flag when creating a new file
Date: Sun, 21 Oct 2001 21:21:16 -0400 (EDT)

 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>
 
State-Changed-From-To: open->closed 
State-Changed-By: mikeh 
State-Changed-When: Tue Nov 6 22:39:38 PST 2001 
State-Changed-Why:  
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. 



http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31420 
>Unformatted:
