bug-bash
[Top][All Lists]
Advanced

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

Re: nullglob option breaks complex parameter expansion/deletion


From: Chet Ramey
Subject: Re: nullglob option breaks complex parameter expansion/deletion
Date: Sat, 02 Jul 2005 12:24:26 -0400
User-agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317)

Michael Wardle wrote:
> Hi Chet
> 
> Thanks for your very prompt reply.
> 
> I understand that globbing is happening, but I don't understand why
> deleting a parameter should occur with nullglob set if the parameter
> matches but the word to delete doesn't.  The bash behavior seems to make
> this construct useful only for file name deletion if nullglob is set,
> when it seems to be useful for any substring deletion if nullglob is
> unset.

The word in question is *not* being parameter expanded.  It is the
result of a *different* parameter expansion:  the unquoted expansion
of $connectioninfo.

Since the results of the parameter expansion of $connectioninfo are
subject to filename expansion, the unquoted `*' in that word is run
through *normal filename expansion*.  Since that expansion looks only
for filenames and, since nullglob is set, deletes words containing
globbing operators that don't match filenames, the word ends up being
removed.

You might get a clearer picture of what's happening if you ran

        echo "$connectioninfo"

and inhibited the filename expansion that normally takes place.

> I also noticed in the POSIX standard that quoting the word part should
> cause it to be literal and prevent globbing.  If I try this in bash, I
> get the same result as in my original message, that is:

You have misunderstood which expansion needs to be quoted.  It's the
expansion of $connectioninfo that needs quoting, as above.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
                                                Live...Laugh...Love
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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