Skip site navigation (1)Skip section navigation (2)
Date:      Sat,  3 Aug 2002 18:17:41 -0400 (EDT)
From:      "David A.Holland" <dholland@eecs.harvard.edu>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/41297: {t,}csh backquote/braces expansion bug
Message-ID:  <20020803221741.5A84F54C659@mail.eecs.harvard.edu>

index | next in thread | raw e-mail


>Number:         41297
>Category:       bin
>Synopsis:       {t,}csh backquote/braces expansion bug
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 03 15:20:01 PDT 2002
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020803221741.5A84F54C659>