aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Aparício <aparicio99@gmail.com>2012-07-19 23:35:40 +0100
committerAndré Aparício <aparicio99@gmail.com>2012-08-03 01:03:41 +0100
commitd8876bc0f19842c9773284af2cee3c61a7dfdc39 (patch)
treeb9cb2f4df56e0fa8b7f97d8392e46e52bf44d9a6
parentParser&Walker: Escape ' (diff)
downloadlibbash-d8876bc0f19842c9773284af2cee3c61a7dfdc39.tar.gz
libbash-d8876bc0f19842c9773284af2cee3c61a7dfdc39.tar.bz2
libbash-d8876bc0f19842c9773284af2cee3c61a7dfdc39.zip
Walker: Fix appending to an array of size 1
-rw-r--r--bashast/libbashWalker.g2
-rw-r--r--scripts/var_def.bash4
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