Date: Tue, 19 Sep 1995 17:12:13 -0700 From: Scott Blachowicz <scott@sabami.seaslug.org> To: FreeBSD-gnats-submit@freebsd.org Cc: scott@sabami.seaslug.org Subject: bin/728: problem with /bin/sh quoting Message-ID: <199509200012.RAA08666@sabami.seaslug.org> Resent-Message-ID: <199509200020.RAA09321@freefall.freebsd.org>
index | next in thread | raw e-mail
>Number: 728
>Category: bin
>Synopsis: /bin/sh messes up quoting when going through eval
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Sep 19 17:20:00 PDT 1995
>Last-Modified:
>Originator: Scott Blachowicz
>Organization:
none
>Release: FreeBSD 2.0-BUILT-19950603 i386
>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.
>Audit-Trail:
>Unformatted:
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199509200012.RAA08666>
