bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Two states of empty arrays


From: Léa Gris
Subject: Two states of empty arrays
Date: Thu, 12 Dec 2019 18:08:46 +0100
User-agent: Telnet/1.0 [tlh] (PDP11/DEC)

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]