[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What has been changed in [[ -v x[@] ]]?
From: |
Peng Yu |
Subject: |
What has been changed in [[ -v x[@] ]]? |
Date: |
Mon, 17 Jul 2023 00:03:08 -0500 |
Hi,
I see the following change in the behavior of [[ -v x[@] ]]. Why is
there such a change?
What is the most efficient way to test whether an associated array is
empty, unset or does not exist?
$ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-apple-darwin18.7.0)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ declare -A x=([a]=1 [b]=2)
$ [[ -v x[@] ]]; echo $?
0
----
$ bash --version
GNU bash, version 5.2.15(1)-release (x86_64-apple-darwin21.6.0)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ declare -A x=([a]=1 [b]=2)
$ [[ -v x[@] ]]; echo $?
1
--
Regards,
Peng
- What has been changed in [[ -v x[@] ]]?,
Peng Yu <=