From fenner@parc.xerox.com  Wed Aug  9 17:26:32 1995
Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93])
          by freefall.FreeBSD.org (8.6.11/8.6.6) with SMTP id RAA05914
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 9 Aug 1995 17:26:31 -0700
Received: from baobab.parc.xerox.com ([13.2.116.113]) by alpha.xerox.com with SMTP id <17778(6)>; Wed, 9 Aug 1995 17:25:53 PDT
Received: (from fenner@localhost) by baobab.parc.xerox.com (8.6.11/8.6.9) id RAA11259; Wed, 9 Aug 1995 17:43:09 -0700
Message-Id: <199508100043.RAA11259@baobab.parc.xerox.com>
Date: Wed, 9 Aug 1995 17:43:09 PDT
From: Bill Fenner <fenner@parc.xerox.com>
Reply-To: fenner@parc.xerox.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: csh doesn't allow !-2*
X-Send-Pr-Version: 3.2

>Number:         669
>Category:       bin
>Synopsis:       csh doesn't allow !-2*
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug  9 17:30:01 PDT 1995
>Closed-Date:    Wed Aug 9 22:46:27 PDT 1995
>Last-Modified:  Wed Aug  9 22:46:54 PDT 1995
>Originator:     Bill Fenner
>Release:        FreeBSD 2.0-BUILT-19950527 i386
>Organization:
Xerox PARC
>Environment:

	

>Description:

	

csh doesn't allow the full history syntax documented in the man page.  The
man page says:

     The `:' separating the event specification from the word designator can
     be omitted if the argument selector begins with a `^', `$', `*' `-' or
     `%'.

However,

% echo !-2*
2*: Event not found.


>How-To-Repeat:

	

Use any of the argument selectors ^, *, - or % after a history command that
is not !!

>Fix:
	
	
Note, I didn't take the time to gain a deep understanding of the code, but
this fixes the immediate problem.  I don't know if it creates new problems.
Someone who knows csh internals (is there anyone left?) might want to review
it to be absolutely sure.

--- bin/csh/lex.c.orig	Tue May 30 00:06:35 1995
+++ bin/csh/lex.c	Thu Aug 10 00:08:22 1995
@@ -1187,7 +1187,7 @@
 	    }
 	    np = lhsb;
 	    event = 0;
-	    while (!cmap(c, _ESC | _META | _QF | _QB) && !any("${}:", c)) {
+	    while (!cmap(c, _ESC | _META | _QF | _QB) && !any("^$*-%{}:", c)) {
 		if (event != -1 && Isdigit(c))
 		    event = event * 10 + c - '0';
 		else
>Release-Note:
>Audit-Trail:

From: =?KOI8-R?Q?=E1=CE=C4=D2=C5=CA_=FE=C5=D2=CE=CF=D7?=
    (aka Andrey A. Chernov, Black Mage) <ache@astral.msk.su>
To: FreeBSD-gnats-submit@freebsd.org, fenner@parc.xerox.com
Cc: bugs@freebsd.org
Subject: Re: bin/669: csh doesn't allow !-2*
Date: Thu, 10 Aug 1995 05:47:34 +0400 (MSD)

 In message <199508100043.RAA11259@baobab.parc.xerox.com> Bill Fenner
     writes:
 
 >However,
 
 >% echo !-2*
 >2*: Event not found.
 
 Just FYI, tcsh does following thing
 
 % echo !-2*
 -2*: Event not found.
 
 >Use any of the argument selectors ^, *, - or % after a history command that
 >is not !!
 
 Can you test it with tcsh too?
 I don't found proper way in 30secs how to test it :-)
 I got "Bad ! arg selector" when I'll try similar "echo" test.
 
 -- 
 Andrey A. Chernov        : And I rest so composedly,  /Now, in my bed,
 ache@astral.msk.su       : That any beholder  /Might fancy me dead -
 FidoNet: 2:5020/230.3    : Might start at beholding me,  /Thinking me dead.
 RELCOM Team,FreeBSD Team :         E.A.Poe         From "For Annie" 1849

From: Bill Fenner <fenner@parc.xerox.com>
To: =?KOI8-R?Q?=E1=CE=C4=D2=C5=CA_=FE=C5=D2=CE=CF=D7?= (aka Andrey A. Chernov, Black Mage) <ache@astral.msk.su>
Cc: FreeBSD-gnats-submit@freebsd.org, fenner@parc.xerox.com, bugs@freebsd.org
Subject: Re: bin/669: csh doesn't allow !-2* 
Date: Wed, 9 Aug 1995 19:23:04 PDT

 In message <JXsKMAme74@astral.msk.su> you write:
 >Can you test it with tcsh too?
 >I don't found proper way in 30secs how to test it :-)
 
 Sorry, I don't have tcsh.
 
 Here is the output from a properly working csh, under SunOS.  (Same results 
 from csh on Solaris 2.x and IRIX):
 
 crevenia% echo 1 2 3
 1 2 3
 crevenia% ;
 crevenia% echo !-2*
 echo 1 2 3
 1 2 3
 crevenia% echo !-3$
 echo 3
 3
 crevenia% echo !-4^
 echo 1
 1
 crevenia% 
 
 Here is the output from FreeBSD's csh:
 
 % echo 1 2 3
 1 2 3
 % ;
 % echo !-2*
 2*: Event not found.
 % echo !-3$
 echo 3
 3
 % echo !-4^
 4^: Event not found.
 %
 
 Note that the "$" case worked.
 
 Here is FreeBSD's csh after applying the patch in my PR.
 
 % echo 1 2 3
 1 2 3
 % ;
 % echo !-2*
 echo 1 2 3
 1 2 3
 % echo !-3$
 echo 3
 3
 % echo !-4^
 echo 1
 1
 %
 
 
   Bill
 
State-Changed-From-To: open->closed 
State-Changed-By: ache 
State-Changed-When: Wed Aug 9 22:46:27 PDT 1995 
State-Changed-Why:  
Fix applied in lex.c v1.3 
>Unformatted:
