bug-bash
[Top][All Lists]
Advanced

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

Re: parameter expansion null check fails for arrays when [*] or [@] is u


From: L A Walsh
Subject: Re: parameter expansion null check fails for arrays when [*] or [@] is used
Date: Tue, 22 Mar 2022 14:51:41 -0700
User-agent: Thunderbird

On 2022/03/21 05:45, Andreas Luik wrote:
Description:
        Bash fails to correctly test for parameter to be unset or null when the 
parameter is an array reference [*] or [@].

Repeat-By:

myvar[0]=
echo "${myvar[0]:+nonnull}"
<empty> -> OK
echo "${myvar[*]:+nonnull}"
nunnull -> not OK, because "${myvar[*]}" is null
myvar[*] = ('', )  element 0 contains an empty string, so not null.

echo "${myvar[@]:+nonnull}"
nunnull -> likewise not OK, because "${myvar[@]}" is null
myvar[@] = ''  (displays all elements, each quoted.  Since
element 1 contains an empty string, it is quoted and isn't null.






reply via email to

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