From d8876bc0f19842c9773284af2cee3c61a7dfdc39 Mon Sep 17 00:00:00 2001 From: André Aparício Date: Thu, 19 Jul 2012 23:35:40 +0100 Subject: Walker: Fix appending to an array of size 1 --- bashast/libbashWalker.g | 2 +- scripts/var_def.bash | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index 34a7660..460ed0c 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -242,7 +242,7 @@ var_def[bool local] } |^(PLUS_ASSIGN libbash_name=name_base { index = walker->get_max_index(libbash_name) + 1; - if(index == 1) // The variable is not defined + if(index == 1 && walker->is_unset_or_null(libbash_name, 0)) index = 0; } array_def_helper[libbash_name, values, index]){ if(local) diff --git a/scripts/var_def.bash b/scripts/var_def.bash index fb6550d..dc47b6c 100644 --- a/scripts/var_def.bash +++ b/scripts/var_def.bash @@ -102,6 +102,10 @@ echo ${ARRAY12[@]} ARRAY13=() ARRAY13+=(4 5 6) echo ${ARRAY13[@]} +ARRAY14=(1) +ARRAY14+=(3) +ARRAY14+=(4 5) +echo ${ARRAY14[@]} declare num=42 echo $num unset num -- cgit v1.2.3-65-gdbad