Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15714 > unrolled thread

Two states of empty arrays

Started byLéa Gris <lea.gris@noiraude.net>
First post2019-12-12 18:08 +0100
Last post2019-12-12 18:08 +0100
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Two states of empty arrays Léa Gris <lea.gris@noiraude.net> - 2019-12-12 18:08 +0100

#15714 — Two states of empty arrays

FromLéa Gris <lea.gris@noiraude.net>
Date2019-12-12 18:08 +0100
SubjectTwo states of empty arrays
Message-ID<mailman.736.1576170542.1979.bug-bash@gnu.org>

[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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web