Re: -v no longer works for associative arrays

2022-10-13 Thread Greg Wooledge
On Thu, Oct 13, 2022 at 02:35:55PM -0400, Chet Ramey wrote: > On 10/13/22 12:47 PM, Bryan Roessler wrote: > > For indexed arrays, yes. I hadn't made the connection with associative > > arrays since I don't typically index them with numbers, thanks. > > There has to be some default, and "0" is at

Re: -v no longer works for associative arrays

2022-10-13 Thread Chet Ramey
On 10/13/22 12:47 PM, Bryan Roessler wrote: For indexed arrays, yes. I hadn't made the connection with associative arrays since I don't typically index them with numbers, thanks. There has to be some default, and "0" is at least consistent with indexed arrays. -- ``The lyf so short, the craft

Re: -v no longer works for associative arrays

2022-10-13 Thread Bryan Roessler
For indexed arrays, yes. I hadn't made the connection with associative arrays since I don't typically index them with numbers, thanks. $ declare -A f[0]=true $ declare -A g[foo]=bar $ test -v f; echo $? 0 $ test -v g; echo $? 1 On Thu, Oct 13, 2022 at 12:10 PM Chet Ramey wrote: > On 10/13/22

Re: -v no longer works for associative arrays

2022-10-13 Thread Oğuz
13 Ekim 2022 Perşembe tarihinde Chet Ramey yazdı: > > You know that referencing an array variable without a subscript is > equivalent to referencing element 0 (or "0"). > Yes, but I didn't know that it applied to test -v as well. Thanks for the reply -- Oğuz

Re: -v no longer works for associative arrays

2022-10-13 Thread Chet Ramey
On 10/13/22 12:06 PM, Oğuz wrote:  test -v seems broken anyway $ declare -A foo=(a 42) $ declare -a bar=(42) $ test -v foo; echo $? 1 $ test -v bar; echo $? 0 You know that referencing an array variable without a subscript is equivalent to referencing element 0 (or "0"). -- ``The lyf so

Re: -v no longer works for associative arrays

2022-10-13 Thread Oğuz
13 Ekim 2022 Perşembe tarihinde Chet Ramey yazdı: > There are other ways to test whether or not an associative array has any > set elements, but there was no way to use `*' or `@' as a key in previous > versions. > test -v seems broken anyway $ declare -A foo=(a 42) $ declare -a bar=(42) $

Re: -v no longer works for associative arrays

2022-10-13 Thread Greg Wooledge
On Thu, Oct 13, 2022 at 10:42:02AM -0400, Bryan Roessler wrote: > Description: > > bash-5.2# declare -A a > bash-5.2# a[foo]=bar > bash-5.2# [[ -v a[@] ]]; echo $? > 1 > > bash-5.1# declare -A a > bash-5.1# a[foo]=bar > bash-5.1# [[ -v a[@] ]]; echo $? > 0 > > If this is by design I missed it.

Re: -v no longer works for associative arrays

2022-10-13 Thread Chet Ramey
On 10/13/22 10:42 AM, Bryan Roessler wrote: Bash Version: 5.2 Patch Level: 2 Release Status: release Description: bash-5.2# declare -A a bash-5.2# a[foo]=bar bash-5.2# [[ -v a[@] ]]; echo $? 1 From CHANGES: j. Associative array assignment and certain instances of referencing (e.g.,