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


Groups > gnu.bash.bug > #15715

Two states of empty arryays

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Léa Gris <lea@nomail.invalid>
Newsgroups gnu.bash.bug
Subject Two states of empty arryays
Date Thu, 12 Dec 2019 17:38:32 +0100
Organization French Data Network
Lines 30
Approved bug-bash@gnu.org
Message-ID <mailman.738.1576170768.1979.bug-bash@gnu.org> (permalink)
References <qstqe9$d93$1@solo.fdn.fr>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1576170768 28057 209.51.188.17 (12 Dec 2019 17:12:48 GMT)
X-Complaints-To action@cs.stanford.edu
To gnu-bash-bug@moderators.isc.org
Envelope-to bug-bash@gnu.org
User-Agent Telnet/1.0 [tlh] (PDP11/DEC)
Content-Language en-US
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy]
X-Received-From 130.133.4.7
X-Mailman-Approved-At Thu, 12 Dec 2019 12:12:47 -0500
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <qstqe9$d93$1@solo.fdn.fr>
Xref csiph.com gnu.bash.bug:15715

Show key headers only | 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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Two states of empty arryays Léa Gris <lea@nomail.invalid> - 2019-12-12 17:38 +0100

csiph-web