bug-bash
[Top][All Lists]
Advanced

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

Re: Inconsistent quote and escape handling in substitution part of param


From: Chet Ramey
Subject: Re: Inconsistent quote and escape handling in substitution part of parameter expansions.
Date: Tue, 28 Feb 2012 17:44:38 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0

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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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