[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with if [ -d in bash 4.3.30
From: |
Chet Ramey |
Subject: |
Re: Problem with if [ -d in bash 4.3.30 |
Date: |
Tue, 09 Dec 2014 10:04:25 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
On 12/9/14, 9:47 AM, Stephane Chazelas wrote:
> 2014-12-09 07:14:16 -0700, Eric Blake:
> [...]
>> No, you get the correct behavior. Newer bash fixed the parser bug to
>> comply with POSIX.
>>
>> For comparison, try:
>>
>> $ echo . ${VAR:=""} .
>> . .
>> $ echo . "${VAR:=""}" .
>> . .
> [...]
>
> It's a bit confusing that ${VAR:-""} should be treated
> differently from ${VAR:=""}. Was there a rationale for changing
> the behaviour other than strict POSIX conformance? AFAICT, ksh
> and mksh behave differently (from bash and from each other), so
> I can't say the change helps much with portability here.
http://austingroupbugs.net/view.php?id=221
"Quote removal is performed when assigning the value in the
${parameter:=word} form of expansion in order that a subsequent
expansion of the same parameter produces the same value as the
original expansion. That is, the commands:
unset parameter
foo=${parameter:=word}
bar=${parameter}
assign the same value to foo and bar. A consequence of this
is that the expansions ${parameter:=word} and ${parameter:-word}
can produce different results for the same word."
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/