[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `$x` adds single quotes during interpolation under Wrong Circumstanc
From: |
Chris F.A. Johnson |
Subject: |
Re: `$x` adds single quotes during interpolation under Wrong Circumstances |
Date: |
Fri, 2 Apr 2004 17:59:42 -0500 (EST) |
On Fri, 2 Apr 2004, 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).
What is the problem? Perhaps we can help? Better still, post it to
the comp.unix.shell newsgroup, as it is not a bug.
> 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's only a single expansion (unless you call removal of the
baskslashes expansion).
First, the backslashes are removed (they are not necessary;
a=*.log* is exactly the same as a=\*.log\*), and "*.log*" is
assigned to a. No expansion is done on assignment.
When you use $a, it may or may not be expanded, depending on
whether or not it is quoted, and whether or not the noglob option
is set.
> 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?
--
Chris F.A. Johnson http://cfaj.freeshell.org
=================================================================
Everything in moderation -- including moderation