[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Does declaring an array variable initialize it?
From: |
Richard Tollerton |
Subject: |
Does declaring an array variable initialize it? |
Date: |
Wed, 19 Mar 2014 23:41:47 -0500 |
User-agent: |
Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-unknown-linux-gnu) |
Old behavior, bash 4.2.45:
$ bash -c 'set -u; echo address@hidden'; \
bash -c 'set -u; declare var1; echo ${#var1}'; \
bash -c 'set -u; declare -a arr2; echo address@hidden'
bash: arr1: unbound variable
bash: var1: unbound variable
0
New behavior, bash 4.3:
$ bash -c 'set -u; echo address@hidden'; \
bash -c 'set -u; declare var1; echo ${#var1}'; \
bash -c 'set -u; declare -a arr2; echo address@hidden'
bash: arr1: unbound variable
bash: var1: unbound variable
bash: arr2: unbound variable
I suppose that this change in behavior makes array variables more
consistent with normal variables, but I couldn't find anything in
CHANGES which obviously relates to this, so I'm not sure if this is a
bug or not.
Was I always mistaken in figuring that declaring an array also
initialized it?
--
Richard Tollerton <address@hidden>
- Does declaring an array variable initialize it?,
Richard Tollerton <=