diff options
author | 2012-07-19 23:35:40 +0100 | |
---|---|---|
committer | 2012-08-03 01:03:41 +0100 | |
commit | d8876bc0f19842c9773284af2cee3c61a7dfdc39 (patch) | |
tree | b9cb2f4df56e0fa8b7f97d8392e46e52bf44d9a6 | |
parent | Parser&Walker: Escape ' (diff) | |
download | libbash-d8876bc0f19842c9773284af2cee3c61a7dfdc39.tar.gz libbash-d8876bc0f19842c9773284af2cee3c61a7dfdc39.tar.bz2 libbash-d8876bc0f19842c9773284af2cee3c61a7dfdc39.zip |
Walker: Fix appending to an array of size 1
-rw-r--r-- | bashast/libbashWalker.g | 2 | ||||
-rw-r--r-- | scripts/var_def.bash | 4 |
2 files changed, 5 insertions, 1 deletions
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 |