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


Groups > gnu.bash.bug > #15717

Re: Two states of empty arrays

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Two states of empty arrays
Date 2019-12-12 14:13 -0500
Message-ID <mailman.740.1576178010.1979.bug-bash@gnu.org> (permalink)
References <c9224e23-ff7d-ba84-dc4f-aa68db902f72@noiraude.net> <79b6365d-4c09-7122-25c3-4564fd304948@case.edu>

Show all headers | View raw


On 12/12/19 12:08 PM, Léa Gris wrote:
> 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[@]}"

This is an unset variable with the array attribute; you have not assigned a
value.


> # Empty array declared without parenthesis
> unset myArr
> declare -a myArr=()

This is an empty array variable; you have assigned a value.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

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


Thread

Re: Two states of empty arrays Chet Ramey <chet.ramey@case.edu> - 2019-12-12 14:13 -0500
  Re: Two states of empty arrays Léa Gris <lea.gris@noiraude.net> - 2019-12-12 22:04 +0100
  Re: Two states of empty arrays Martin Schulte <gnu@schrader-schulte.de> - 2019-12-12 22:34 +0100

csiph-web