X-Authentication-Warning: kendall.sfbr.org: jeffw set sender to jeffw AT darwin DOT sfbr DOT org using -f Date: Tue, 23 Oct 2001 07:57:09 -0500 From: JT Williams To: djgpp AT delorie DOT com Cc: "Mark E." Subject: Re: bash 2.04: $# not preserved? Message-ID: <20011023075709.A25230@kendall.sfbr.org> Mail-Followup-To: djgpp AT delorie DOT com, "Mark E." References: <20011018115345 DOT A21027 AT kendall DOT sfbr DOT org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from snowball3@bigfoot.com on Mon, Oct 22, 2001 at 03:09:37PM -0400 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk -: 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 (); }