#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 &' */
{
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)
#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)
{
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
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_ */
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;
}
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;