Mail Archives: djgpp/2001/10/23/09:01:34
-: So -- going by the comment quoted above -- the Solaris example does
-: seem to report the correct value, but I can't find any code in Bash
-: that detects when the "dollar vars" have changed and behave like the
-: Solaris example.
It seems to be tied up with DESTRUCTIVE, in builtins/common.c (see
below). Every instance of remember_args that I can find is called with
destructive=1, but it isn't clear (to me) if that is responsible for
the observed behavior.
jtw
---
/* Remember LIST in $0 ... $9, and REST_OF_ARGS. If DESTRUCTIVE is
non-zero, then discard whatever the existing arguments are, else
only discard the ones that are to be replaced. */
void
remember_args (list, destructive)
WORD_LIST *list;
int destructive;
{
register int i;
for (i = 1; i < 10; i++)
{
if ((destructive || list) && dollar_vars[i])
{
free (dollar_vars[i]);
dollar_vars[i] = (char *)NULL;
}
if (list)
{
dollar_vars[i] = savestring (list->word->word);
list = list->next;
}
}
/* If arguments remain, assign them to REST_OF_ARGS.
Note that copy_word_list (NULL) returns NULL, and
that dispose_words (NULL) does nothing. */
if (destructive || list)
{
dispose_words (rest_of_args);
rest_of_args = copy_word_list (list);
}
if (destructive)
set_dollar_vars_changed ();
}
- Raw text -