bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `$x` adds single quotes during interpolation under Wrong Circumstanc


From: Chet Ramey
Subject: Re: `$x` adds single quotes during interpolation under Wrong Circumstances
Date: Tue, 13 Apr 2004 17:32:53 -0400
User-agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.6) Gecko/20040113

philo vivero wrote:

On Fri, 2004-04-02 at 07:14, Paul Jarc wrote:

philo vivero <phiviv@hacklab.net> wrote:

How can I make "echo $a" return "*.log*" if there is a file called
"install.log.syslog" in the cwd?

echo "$a"


echo "$a" != echo $a -- this is not pedantic.

It makes a particular function impossible to write (of course I could do
kludgery by changing CWD to some directory that I know doesn't contain
certain files, but I hope you don't recommend this).

I'm hoping you can tell me that there's a good reason that this:

a=\*.log\*
echo $a

does a double-expansion. First $a is expanded out to "*.log*" *THEN*
that is further expanded to install.log.syslog

There is no `double expansion'.

The rhs of the assignment statement is expanded, resulting in "*.log*".
The backslashes are removed as part of quote removal.  This is as you
have observed.

When $a is expanded, the results are available for pathname expansion,
if unquoted.  This is how sh has always behaved.

Posix explains the process pretty well:

http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_06

If this is a
feature-not-a-bug I really don't mind dropping this issue. But I still
feel it's a bug. Would you accept a patch?

No.  The incompatibility and breakage is not worth it.

Chet




reply via email to

[Prev in Thread] Current Thread [Next in Thread]