From root@kutulu.org  Sat Dec  1 18:00:07 2001
Return-Path: <root@kutulu.org>
Received: from pr0n.kutulu.org (pr0n.kutulu.org [151.196.107.157])
	by hub.freebsd.org (Postfix) with ESMTP id 93B4C37B405
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  1 Dec 2001 18:00:05 -0800 (PST)
Received: by pr0n.kutulu.org (Postfix, from userid 0)
	id A8B044CA; Sat,  1 Dec 2001 21:00:55 -0500 (EST)
Message-Id: <20011202020055.A8B044CA@pr0n.kutulu.org>
Date: Sat,  1 Dec 2001 21:00:55 -0500 (EST)
From: kutulu <kutulu@kutulu.org>
Reply-To: kutulu <kutulu@kutulu.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Cannot specify files beginning with + on ee command line.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         32433
>Category:       bin
>Synopsis:       Cannot specify files beginning with + on ee command line.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 01 18:10:01 PST 2001
>Closed-Date:    Mon Jul 14 00:30:27 PDT 2003
>Last-Modified:  Mon Jul 14 00:30:27 PDT 2003
>Originator:     kutulu
>Release:        FreeBSD 4.4-STABLE i386
>Organization:
KutuluWare Software Services
>Environment:
System: FreeBSD pr0n.kutulu.org 4.4-STABLE FreeBSD 4.4-STABLE #1: Mon Oct 29 16:56:42 EST 2001 root@pr0n.kutulu.org:/usr/obj/usr/src/sys/PR0N i386


	
>Description:
The 'ee' command accepts a +# parameter, allowing one to jump 
immediately to a given line of the file specified on the command 
line.  This makes it impossible to edit files beginning with a +
without resorting to unusual syntax.  For ee, at least, tehre is
a simple fix for this problem.

(For the record, pico, vi, and vim also suffer from this problem,
however, vi/vim have alternate command-line options that start
with +, so the fix is not nearly as obvious).

>How-To-Repeat:

echo "This is a text file" > +CONTENTS
ee +CONTENTS

>Fix:

A work-around for this problem is to specify a pathname to the 
file that does not begin with +, as in:

ee ./+CONTENTS
ee /var/pkg/db/zip-2.3/+DESC

This perhaps should be mentioned in the 'ee' man page,
especially given the presumed target audience for ee (namely,
beginners to FreeBSD and UNIX in general.)

However, since the only valid options for the + command-lnie
paramter are digits, ee can be fixed to work the way users
probably want it to work by simply ignoring + before non-digits:

--- usr.bin/ee/ee.c.old Sat Dec  1 20:40:09 2001
+++ usr.bin/ee/ee.c     Sat Dec  1 20:41:45 2001
@@ -2094,7 +2094,8 @@
                else if (*buff == '+')
                {
                        buff++;
-                       start_at_line = buff;
+                       if isdigit(*buff)
+                               start_at_line = buff;
                }
 
                else


>Release-Note:
>Audit-Trail:

From: "Kutulu" <kutulu@kutulu.org>
To: <freebsd-gnats-submit@FreeBSD.org>, "Kutulu" <kutulu@kutulu.org>
Cc:  
Subject: Re: bin/32433: Cannot specify files beginning with + on ee command line.
Date: Sat, 1 Dec 2001 22:02:43 -0500

 And of course, I completely screwed up the patch.  This is why I should
 leave this stuff up to the professionals.  This one works, but it looks
 ugly, so I'm sure there's a better way:
 
 --- ee.c.old    Sat Dec  1 20:40:09 2001
 +++ ee.c        Sat Dec  1 22:07:13 2001
 @@ -2091,7 +2091,7 @@
                         fprintf(stderr, usage4);
                         exit(1);
                 }
 -               else if (*buff == '+')
 +               else if ((*buff == '+') && (isdigit(*(buff + 1))))
                 {
                         buff++;
                         start_at_line = buff;
 
 --K
 

From: Ruslan Ermilov <ru@FreeBSD.org>
To: Kutulu <kutulu@kutulu.org>
Cc: bug-followup@FreeBSD.org, Hugh Mahon <h_mahon@fc.hp.com>
Subject: Re: bin/32433: Cannot specify files beginning with + on ee command line.
Date: Mon, 3 Dec 2001 16:38:14 +0200

 On Sat, Dec 01, 2001 at 07:10:01PM -0800, Kutulu wrote:
 > The following reply was made to PR bin/32433; it has been noted by GNATS.
 > 
 > From: "Kutulu" <kutulu@kutulu.org>
 > To: <freebsd-gnats-submit@FreeBSD.org>, "Kutulu" <kutulu@kutulu.org>
 > Cc:  
 > Subject: Re: bin/32433: Cannot specify files beginning with + on ee command line.
 > Date: Sat, 1 Dec 2001 22:02:43 -0500
 > 
 >  And of course, I completely screwed up the patch.  This is why I should
 >  leave this stuff up to the professionals.  This one works, but it looks
 >  ugly, so I'm sure there's a better way:
 >  
 >  --- ee.c.old    Sat Dec  1 20:40:09 2001
 >  +++ ee.c        Sat Dec  1 22:07:13 2001
 >  @@ -2091,7 +2091,7 @@
 >                          fprintf(stderr, usage4);
 >                          exit(1);
 >                  }
 >  -               else if (*buff == '+')
 >  +               else if ((*buff == '+') && (isdigit(*(buff + 1))))
 >                  {
 >                          buff++;
 >                          start_at_line = buff;
 >  
 Err, this patch is not quite correct either, as it won't allow to
 open files with a digit after a plus sign.  The correct thing to
 here would be to check that there's still argument pending on a
 command line, as "+offset" doesn't make any sense if specified
 as a last argument.  ee(1) is the contributed software, and hence
 doesn't use an unportable getopt(3) interface.  I'd also suggest
 that the author introduce the support for "--" (cancel options
 list processing), then the problem could be easily avoided (the
 Unix way) like this: "ee ... +10 -- <any_name>".  Currently,
 opening a file with the name of "-[ieh?]" doesn't work as well.
 I've Cc:ed the author of this program.
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Oracle Developer/DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Mon Dec 3 18:01:43 PST 2001 
State-Changed-Why:  
Use 'ee -- +CONTENTS'.  This is standard behaviour for most Unix programs. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=32433 
State-Changed-From-To: closed->open 
State-Changed-By: des 
State-Changed-When: Mon Dec 3 18:02:32 PST 2001 
State-Changed-Why:  
Closed by mistake, I misunderstood the issue. 

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

From: Zak Johnson <zakj@nox.cx>
To: freebsd-gnats-submit@FreeBSD.org, kutulu@kutulu.org
Cc:  
Subject: Re: bin/32433: Cannot specify files beginning with + on ee command line.
Date: Wed, 19 Jun 2002 19:05:53 -0400

 Support for '--' to cancel options list processing has been added to ee
 as of (at least) the current version, which is available at
 http://mahon.cwx.net/sources/ee-1.4.5a.src.tgz .  Alternately, this
 patch should do the trick.
 
 -Zak
 
 --- ee.c.orig	Sun Jun 16 00:49:28 2002
 +++ ee.c	Wed Jun 19 19:00:43 2002
 @@ -2051,6 +2051,7 @@
  	struct files *temp_names = NULL;
  	char *name;
  	char *ptr;
 +	int no_more_opts = FALSE;
  
  	/*
  	 |	see if editor was invoked as 'ree' (restricted mode)
 @@ -2067,7 +2068,7 @@
  	input_file = FALSE;
  	recv_file = FALSE;
  	count = 1;
 -	while (count < numargs)
 +	while ((count < numargs) && (!no_more_opts))
  	{
  		buff = arguments[count];
  		if (!strcmp("-i", buff))
 @@ -2096,7 +2097,8 @@
  			buff++;
  			start_at_line = buff;
  		}
 +		else if (!(strcmp("--", buff)))
 +			no_more_opts = TRUE;
  		else
  		{
  			if (top_of_stack == NULL)
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Mon Jun 30 04:53:33 PDT 2003 
State-Changed-Why:  
Added a support for '--' to cancel options list processing in -CURRENT. 


Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Mon Jun 30 04:53:33 PDT 2003 
Responsible-Changed-Why:  
MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=32433 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Mon Jul 14 00:30:06 PDT 2003 
State-Changed-Why:  
Fixed in -STABLE as well. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=32433 
>Unformatted:
