On 2/28/12 5:30 PM, Maarten Billemont wrote:

>>> 1${A:-B}2
>>>
>>> Logically for consistancy having double quotes at position 1 and 2
>>> should have no effect on how you treat string B.
>>
>> Maybe, but that's not how things work in practice.  Should the following
>> expansions output the same thing?  What should they output?
>>
>> bar=abc
>> echo ${foo:-'$bar'}
>> echo "${foo:-'$bar'}"
>>
>> Chet
> 
> 
> Personally, I'd prefer it to behave in the same way bash deals with this sort 
> of thing in other contexts.

You'd be surprised.

> Eg.
> 
> echo $(echo '$bar')
> echo "$(echo '$bar')"
> 
> Both obviously result in <$bar> getting output.

New-style command substitutions are treated differently.

> For the sake of consistency with the rest of bash, I would expect the same 
> from your example.=

No shell behaves like that.  Everyone outputs

$bar
'abc'

and Posix requires it.

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

Reply via email to