bug-bash
[Top][All Lists]
Advanced

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

Re: Empty ""s in ARG in ${x:+ARG} expand to no words instead of the empt


From: Chet Ramey
Subject: Re: Empty ""s in ARG in ${x:+ARG} expand to no words instead of the empty word if prepended/appended with space
Date: Sat, 21 Jul 2018 11:33:18 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 7/21/18 12:44 AM, Bob Proulx wrote:
> Denys Vlasenko wrote:
>> $ f() { for i; do echo "|$i|"; done; }
>> $ x=x
>> $ e=
>> $ f ${x:+ ""}
>> ^^^^^^^^^^^ prints nothing, bug?
>>
>> $  ${x:+"" }
>> ^^^^^^^^^^^ prints nothing, bug?
> 
> Insufficient quoting.  That argument should be quoted to avoid the
> whitespace getting stripped.  (Is that during word splitting phase
> using the IFS?  I think so.)

Even if the whitespace gets stripped out, the quoted null string should
result in an empty argument. Different shells are inconsistent about this,
but I believe that if word splitting occurs, the empty string (or "$e",
anything that expands to an empty string) should result in a null word.

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



reply via email to

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