help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Unquoted $@ inside [[ ... ]]


From: Chet Ramey
Subject: Re: [Help-bash] Unquoted $@ inside [[ ... ]]
Date: Sun, 20 Apr 2014 22:34:18 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

On 4/18/14, 4:21 PM, Greg Wooledge wrote:
> Someone in IRC had some code whose behavior I don't really understand.
> The code in question was:
> 
>    if [[ $@ == $','* ]]
> 
> At first glance this looks like it's just equivalent to:
> 
>    if [[ $1 = ,* ]]
> 
> But as it turns out, this is not the case.

It's a bug.  There are slight differences in how bash expands unquoted $*
and $@ in different contexts.  Try the attached patch for a proposed fix.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

Attachment: dollar-at-star.patch
Description: Text Data


reply via email to

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