aboutsummaryrefslogtreecommitdiffstats
path: root/builtins/declare.def
diff options
context:
space:
mode:
Diffstat (limited to 'builtins/declare.def')
-rw-r--r--builtins/declare.def28
1 files changed, 20 insertions, 8 deletions
diff --git a/builtins/declare.def b/builtins/declare.def
index fe112dd..d94118f 100644
--- a/builtins/declare.def
+++ b/builtins/declare.def
@@ -1,7 +1,7 @@
This file is declare.def, from which is created declare.c.
It implements the builtins "declare" and "local" in Bash.
-Copyright (C) 1987-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2004 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -222,18 +222,24 @@ declare_internal (list, local_var)
while (list) /* declare [-afFirx] name [name ...] */
{
char *value, *name;
- int offset;
+ int offset, aflags;
#if defined (ARRAY_VARS)
int making_array_special, compound_array_assign, simple_array_assign;
#endif
name = savestring (list->word->word);
offset = assignment (name, 0);
+ aflags = 0;
if (offset) /* declare [-afFirx] name=value */
{
name[offset] = '\0';
value = name + offset + 1;
+ if (name[offset - 1] == '+')
+ {
+ aflags |= ASS_APPEND;
+ name[offset - 1] = '\0';
+ }
}
else
value = "";
@@ -353,7 +359,7 @@ declare_internal (list, local_var)
var = make_new_array_variable (name);
else
#endif
- var = bind_variable (name, "");
+ var = bind_variable (name, "", 0);
}
/* Cannot use declare +r to turn off readonly attribute. */
@@ -377,7 +383,13 @@ declare_internal (list, local_var)
#if defined (ARRAY_VARS)
if ((making_array_special || (flags_on & att_array) || array_p (var)) && offset)
{
+ int vlen;
+ vlen = STRLEN (value);
+#if 0
if (value[0] == '(' && strchr (value, ')'))
+#else
+ if (value[0] == '(' && value[vlen-1] == ')')
+#endif
compound_array_assign = 1;
else
simple_array_assign = 1;
@@ -401,23 +413,23 @@ declare_internal (list, local_var)
#if defined (ARRAY_VARS)
if (offset && compound_array_assign)
- assign_array_var_from_string (var, value);
+ assign_array_var_from_string (var, value, aflags);
else if (simple_array_assign && subscript_start)
{
/* declare [-a] name[N]=value */
*subscript_start = '['; /* ] */
- var = assign_array_element (name, value);
+ var = assign_array_element (name, value, 0); /* XXX - not aflags */
*subscript_start = '\0';
}
else if (simple_array_assign)
/* let bind_array_variable take care of this. */
- bind_array_variable (name, 0, value);
+ bind_array_variable (name, 0, value, aflags);
else
#endif
/* bind_variable_value duplicates the essential internals of
bind_variable() */
if (offset)
- bind_variable_value (var, value);
+ bind_variable_value (var, value, aflags);
/* If we found this variable in the temporary environment, as with
`var=value declare -x var', make sure it is treated identically
@@ -437,7 +449,7 @@ declare_internal (list, local_var)
if (tv)
{
tvalue = var_isset (var) ? savestring (value_cell (var)) : savestring ("");
- tv = bind_variable (var->name, tvalue);
+ tv = bind_variable (var->name, tvalue, 0);
tv->attributes |= var->attributes & ~att_tempvar;
if (tv->context > 0)
VSETATTR (tv, att_propagate);