From dholland@eecs.harvard.edu  Sat Aug  3 15:17:42 2002
Return-Path: <dholland@eecs.harvard.edu>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9220137B400
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  3 Aug 2002 15:17:42 -0700 (PDT)
Received: from mail.eecs.harvard.edu (bowser.eecs.harvard.edu [140.247.60.24])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 327E043E4A
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  3 Aug 2002 15:17:42 -0700 (PDT)
	(envelope-from dholland@eecs.harvard.edu)
Received: by mail.eecs.harvard.edu (Postfix, from userid 32170)
	id 5A84F54C659; Sat,  3 Aug 2002 18:17:41 -0400 (EDT)
Message-Id: <20020803221741.5A84F54C659@mail.eecs.harvard.edu>
Date: Sat,  3 Aug 2002 18:17:41 -0400 (EDT)
From: David A.Holland <dholland@eecs.harvard.edu>
Reply-To: David A.Holland <dholland@eecs.harvard.edu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: {t,}csh backquote/braces expansion bug
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         41297
>Category:       bin
>Synopsis:       tcsh(1)/csh(1) backquote/braces expansion bug
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    eadler
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 03 15:20:01 PDT 2002
>Closed-Date:    Fri May 11 23:10:07 UTC 2012
>Last-Modified:  Fri May 11 23:10:29 UTC 2012
>Originator:     David A. Holland
>Release:        FreeBSD 4.5-RELEASE i386
>Organization:
Harvard EESC
>Environment:
System: FreeBSD bowser.eecs.harvard.edu 4.5-RELEASE FreeBSD 4.5-RELEASE #1: Tue Jun 25 16:51:02 EDT 2002 palmer@bowser.eecs.harvard.edu:/usr/src/sys/compile/BOWSER i386

	tcsh 6.11.00 was built from ports.

>Description:

If you write a program "foo" that prints

   echo '{'

and then type

   echo `foo`

tcsh incorrectly prints "Missing }."

Similarly, if you have foo print

   echo '{a,b,c}'

tcsh prints "echo 'a' 'b' 'c'".

Observed with:
   tcsh 6.09 for i386-intel-NetBSD
   tcsh 6.10 for i386-intel-linux
   tcsh 6.11 for i386-intel-FreeBSD
and also
   csh from FreeBSD 4.5-RELEASE
   csh from NetBSD 1.6-current

What happens is that globexpand() in sh.glob.c is called to handle the
backquotes, which is correct; however, after expanding the backquotes,
globexpand proceeds to also expand braces, tilde, and some other
things. None of these expansions check for or honor quotes (either
single or double quotes) and this produces the problem.

I don't claim to know enough about the inner workings of expansions in
csh to suggest a correct fix. Probably the results of backquote
expansion need to be rescanned for quotes earlier than they are.
(They apparently are at some point, although I haven't found the code
yet.)

This problem gets tickled when using the X11 "resize" command in
connection with a termcap entry that contains braces, as some do, but
is more or less silent as long as the braces match, which generally in
the past they have. (However, FreeBSD seems to have recently introduced
an xterm termcap entry where the braces don't match. This broke my
login and caused me to investigate.)

The problem also affects FreeBSD and NetBSD's /bin/csh and, in fact,
probably every csh. Therefore, copies of this message are being sent
to various additional appropriate places.

>How-To-Repeat:

	See above.

>Fix:
	As a workaround to the immediate problem, the status quo can
	be restored by restoring the matching braces to the termcap file.

	Also see above.



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->mp 
Responsible-Changed-By: mp 
Responsible-Changed-When: Sun Aug 4 12:16:58 PDT 2002 
Responsible-Changed-Why:  
I'll take this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41297 
State-Changed-From-To: open->feedback  
State-Changed-By: brucec 
State-Changed-When: Tue Jul 15 17:34:41 UTC 2008 
State-Changed-Why:  
tcsh 6.15.00 was imported into RELENG_6 a few months ago and looks like it might have fixed the problem. Are you still seeing this issue on 6-STABLE?  

http://www.freebsd.org/cgi/query-pr.cgi?pr=41297 

From: Bruce Cran <bruce@cran.org.uk>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/41297: tcsh(1)/csh(1) backquote/braces expansion bug
Date: Wed, 16 Jul 2008 21:41:36 +0100

 --Sig_/i2s5k.zwpIfyB2umnFledWz
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: quoted-printable
 
 Begin forwarded message:
 
 Date: Tue, 15 Jul 2008 14:04:47 -0400
 From: David Holland <dholland@eecs.harvard.edu>
 To: brucec@FreeBSD.org
 Cc: dholland@eecs.harvard.edu, mp@FreeBSD.org
 Subject: Re: bin/41297: tcsh(1)/csh(1) backquote/braces expansion bug
 
 
 On Tue, Jul 15, 2008 at 05:39:32PM +0000, brucec@FreeBSD.org wrote:
  > Synopsis: tcsh(1)/csh(1) backquote/braces expansion bug
  >=20
  > State-Changed-From-To: open->feedback=20
  > State-Changed-By: brucec
  > State-Changed-When: Tue Jul 15 17:34:41 UTC 2008
  > State-Changed-Why:=20
  > tcsh 6.15.00 was imported into RELENG_6 a few months ago and looks
 like it might have fixed the problem. Are you still seeing this issue
 on 6-STABLE? > > http://www.freebsd.org/cgi/query-pr.cgi?pr=3D41297
 
 I don't have such a machine, but tcsh 6.15.00 on NetBSD still has the
 problem:
 
    tanaqui% cat foo.c
    #include <stdio.h>
    int main() {
       printf("echo '{a,b,c}'\n");
       return 0;
    }
    tanaqui% gcc foo.c -o foo
    tanaqui% ./foo
    echo '{a,b,c}'
    tanaqui% echo `./foo`
    echo 'a' 'b' 'c'
    tanaqui% echo $version
    tcsh 6.15.00 (Astron) 2007-03-03 (i386-intel-NetBSD) options
    wide,nls,dl,al,kan,rh,color,filec
    tanaqui%=20
 
 (And, FWIW, it also still affects /bin/csh in 6.0-RELEASE-p18.)
 
 This issue is also
 http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=3D17826
 where we haven't done anything about it either...
 
 --=20
    - David A. Holland / dholland@eecs.harvard.edu
 
 
 --Sig_/i2s5k.zwpIfyB2umnFledWz
 Content-Type: application/pgp-signature; name=signature.asc
 Content-Disposition: attachment; filename=signature.asc
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)
 
 iD8DBQFIfl0En4uvqcJsLfgRAvwkAKClEOVA4x4N/sedqNLTb25zZs5sjACcCAmh
 Z+PizXcnT9fl/41sFlwkQhY=
 =p2QV
 -----END PGP SIGNATURE-----
 
 --Sig_/i2s5k.zwpIfyB2umnFledWz--
State-Changed-From-To: feedback->open  
State-Changed-By: brucec 
State-Changed-When: Wed Jul 16 20:52:04 UTC 2008 
State-Changed-Why:  
Feedback was received. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41297 
State-Changed-From-To: open->closed 
State-Changed-By: eadler 
State-Changed-When: Fri May 11 23:10:04 UTC 2012 
State-Changed-Why:  
not reproducable in HEAD 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41297 
Responsible-Changed-From-To: mp->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Fri May 11 23:10:26 UTC 2012 
Responsible-Changed-Why:  
I closed it. 

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