Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to substitute empty array element, or empty string



On 3/25/17 2:21 AM, Sebastian Gniazdowski wrote:
> On 24 marca 2017 at 12:50:43, Peter Stephenson (p.stephenson@xxxxxxxxxxx) wrote: 
>> [[ '' = * ]] && echo yes
>>  
>> echoes "yes" in bash as well as zsh, so "*" can match an empty string,
>> and I don't think the / and // operators are standardised.
> 
> Checked that in ksh:
> 
> % a=""; echo ${a//*/x}
> x
> % a=( "" ); echo ${a[@]//*/x}
> x
> % [[ "" = * ]] && echo yes
> yes
> 
> It can look like // behavior was bash-driven, and in bash there is the omission for "".

This was changed between bash-4.3 and bash-4.4.

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



Messages sorted by: Reverse Date, Date, Thread, Author