[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to test if a variable exists and is a hash?
From: |
Peng Yu |
Subject: |
How to test if a variable exists and is a hash? |
Date: |
Sat, 11 Jul 2020 10:43:28 -0500 |
$ declare -A x=([a]=10); [[ -v x ]]; echo $?
1
-v can not test if a hash is declared.
`declare -p x 2> /dev/null` can not tell whether it is a hash or a variable.
What is the best way to check if a variable exists and is a hash? Thanks.
--
Regards,
Peng
- How to test if a variable exists and is a hash?,
Peng Yu <=