From sabami.seaslug.org!scott@statsci.com  Tue Sep 19 17:13:26 1995
Received: from statsci.statsci.com (statsci.statsci.com [198.145.127.9])
          by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id RAA09217
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 Sep 1995 17:13:25 -0700
Received: by statsci.statsci.com (Smail3.1.28.1 #3)
	id m0svCih-0005iSC; Tue, 19 Sep 95 17:08 PDT
Received: (from scott@localhost) by sabami.seaslug.org (8.6.11/8.6.9) id RAA08666; Tue, 19 Sep 1995 17:12:13 -0700
Message-Id: <199509200012.RAA08666@sabami.seaslug.org>
Date: Tue, 19 Sep 1995 17:12:13 -0700
From: Scott Blachowicz <scott@sabami.seaslug.org>
Reply-To: scott@sabami.seaslug.org
To: FreeBSD-gnats-submit@freebsd.org
Cc: scott@sabami.seaslug.org
Subject: problem with /bin/sh quoting
X-Send-Pr-Version: 3.2

>Number:         728
>Category:       bin
>Synopsis:       /bin/sh messes up quoting when going through eval
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    joerg
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 19 17:20:00 PDT 1995
>Closed-Date:    Sun Sep 1 05:31:14 PDT 1996
>Last-Modified:  Sun Sep  1 05:31:55 PDT 1996
>Originator:     Scott Blachowicz
>Release:        FreeBSD 2.0-BUILT-19950603 i386
>Organization:
none
>Environment:

	FreeBSD 2.0.5 from the Walnut Creek CDROM.

>Description:

   /bin/sh has a problem with quoting in something like this sample
   case (distilled down from a more complicated script that I've used for
   years on various OSs):

	x2=XX
	n=2
	t=`eval echo \\\$x$n`
	echo $t

   On everything (HPUX, SunOS, Solaris, IRIX, AIX, DEC OSF1) except
   FreeBSD, that produces 'XX' as output. FreeBSD gives '2' as the
   output.

>How-To-Repeat:

Put these lines in a file (e.g. "test-quoting"):

	#! /bin/sh
	x2=XX
	n=2
	t=`eval echo \\\$x$n`
	echo $t

Season with a little execute permission.

	chmod a+x test-quoting

Then run

	./test-quoting

If it outputs "XX", then it's acting as I expect it to. If it outputs "2"
then it isn't.

>Fix:
	
   [WORKAROUND]

   If a bit of redirection is introduced for the dollar sign:

	d='$'
	t=`eval echo ${d}x$n`

   then it works.


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->joerg 
Responsible-Changed-By: joerg 
Responsible-Changed-When: Fri Apr 12 23:36:24 MET DST 1996 
Responsible-Changed-Why:  
I'm goinmg to deal with sh(1) bugs some day. 
State-Changed-From-To: open->closed 
State-Changed-By: peter 
State-Changed-When: Sun Sep 1 05:31:14 PDT 1996 
State-Changed-Why:  
Fixed after 4.4Lite2 sh merge 
>Unformatted:

