Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15714
| From | Léa Gris <lea.gris@noiraude.net> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Two states of empty arrays |
| Date | 2019-12-12 18:08 +0100 |
| Message-ID | <mailman.736.1576170542.1979.bug-bash@gnu.org> (permalink) |
| References | <c9224e23-ff7d-ba84-dc4f-aa68db902f72@noiraude.net> |
[Multipart message — attachments visible in raw view] - view raw
Hello,
Depending on how an empty array is declared, it is not stored with the
same state.
# Empty array declared without parenthesis
unset myArr
declare -a myArr
typeset -p myArr
echo "${#myArr[@]}"
output:
declare -a myArr
0
# Empty array declared without parenthesis
unset myArr
declare -a myArr=()
typeset -p myArr
echo "${#myArr[@]}"
output:
declare -a myArr=()
0
What is the reason for having different states for empty arrays?
--
Lea Gris
--
Léa Gris
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Two states of empty arrays Léa Gris <lea.gris@noiraude.net> - 2019-12-12 18:08 +0100
csiph-web