summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2012-05-07 16:22:49 -0400
committerChet Ramey <chet.ramey@case.edu>2012-05-07 16:22:49 -0400
commit6d41b71587a48f90a555846477b2ff6a976d766d (patch)
tree54cb661d48bc28bec5ec07dca99501519115fd29
parent6c19148d3350504ff170ca6fabc9b120ad3f3378 (diff)
downloadbash-6d41b71587a48f90a555846477b2ff6a976d766d.tar.gz
Bash-4.2 patch 25
-rw-r--r--command.h1
-rw-r--r--execute_cmd.c16
-rw-r--r--patchlevel.h2
-rw-r--r--subst.c7
4 files changed, 19 insertions, 7 deletions
diff --git a/command.h b/command.h
index 5d620468..fb712297 100644
--- a/command.h
+++ b/command.h
@@ -97,6 +97,7 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#define W_HASCTLESC 0x200000 /* word contains literal CTLESC characters */
#define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
#define W_ARRAYIND 0x800000 /* word is an array index being expanded */
+#define W_ASSNGLOBAL 0x1000000 /* word is a global assignment to declare (declare/typeset -g) */
/* Possible values for subshell_environment */
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
diff --git a/execute_cmd.c b/execute_cmd.c
index 30b04601..3f9c1507 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -3580,13 +3580,13 @@ fix_assignment_words (words)
{
WORD_LIST *w;
struct builtin *b;
- int assoc;
+ int assoc, global;
if (words == 0)
return;
b = 0;
- assoc = 0;
+ assoc = global = 0;
for (w = words; w; w = w->next)
if (w->word->flags & W_ASSIGNMENT)
@@ -3603,12 +3603,17 @@ fix_assignment_words (words)
#if defined (ARRAY_VARS)
if (assoc)
w->word->flags |= W_ASSIGNASSOC;
+ if (global)
+ w->word->flags |= W_ASSNGLOBAL;
#endif
}
#if defined (ARRAY_VARS)
/* Note that we saw an associative array option to a builtin that takes
assignment statements. This is a bit of a kludge. */
- else if (w->word->word[0] == '-' && strchr (w->word->word, 'A'))
+ else if (w->word->word[0] == '-' && (strchr (w->word->word+1, 'A') || strchr (w->word->word+1, 'g')))
+#else
+ else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g'))
+#endif
{
if (b == 0)
{
@@ -3618,10 +3623,11 @@ fix_assignment_words (words)
else if (b && (b->flags & ASSIGNMENT_BUILTIN))
words->word->flags |= W_ASSNBLTIN;
}
- if (words->word->flags & W_ASSNBLTIN)
+ if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A'))
assoc = 1;
+ if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g'))
+ global = 1;
}
-#endif
}
/* Return 1 if the file found by searching $PATH for PATHNAME, defaulting
diff --git a/patchlevel.h b/patchlevel.h
index 4f922469..c8093cc1 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 24
+#define PATCHLEVEL 25
#endif /* _PATCHLEVEL_H_ */
diff --git a/subst.c b/subst.c
index 9feaa9c2..c9a06788 100644
--- a/subst.c
+++ b/subst.c
@@ -366,6 +366,11 @@ dump_word_flags (flags)
f &= ~W_ASSNBLTIN;
fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");
}
+ if (f & W_ASSNGLOBAL)
+ {
+ f &= ~W_ASSNGLOBAL;
+ fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : "");
+ }
if (f & W_COMPASSIGN)
{
f &= ~W_COMPASSIGN;
@@ -2803,7 +2808,7 @@ do_assignment_internal (word, expand)
}
else if (assign_list)
{
- if (word->flags & W_ASSIGNARG)
+ if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0)
aflags |= ASS_MKLOCAL;
if (word->flags & W_ASSIGNASSOC)
aflags |= ASS_MKASSOC;