From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2679 invoked from network); 21 Nov 1999 22:41:46 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 Nov 1999 22:41:46 -0000 Received: (qmail 11439 invoked by alias); 21 Nov 1999 22:41:40 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8704 Received: (qmail 11432 invoked from network); 21 Nov 1999 22:41:39 -0000 Subject: Re: A couple of bugs in zsh-3.0.7 In-Reply-To: from James Antill at "Nov 21, 1999 5:22: 4 pm" To: james@and.org Date: Sun, 21 Nov 1999 22:41:37 +0000 (GMT) Cc: zsh-workers@sunsite.auc.dk X-Mailer: ELM [version 2.4ME+ PL48 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: From: Zefram James Antill wrote: >% alias abcd="echo abcd" >% abcd () { echo xyz >2> } > /* running abcd at this point crashes zsh */ This is not a bug. It's a rather unintuitive, but standard, interaction between aliases and functions. The word "abcd", when it is defined as an alias, gets expanded anywhere that it appears in a command position. The catch is that in the traditional function definition syntax, the name of the function being defined is in command position. So the alias gets expanded, and you end up doing echo abcd () { echo xyz; } The next catch is that this defines *both* "echo" and "abcd" as functions, with the body you gave. "echo" is a function that calls itself. When you run the "abcd" function, it calls the "echo" function, which calls itself recursively until the stack overflows. There are three ways to avoid this. Firstly, don't mix aliases and functions, or at least define all functions before aliases. Secondly, escape the command word when defining a function, to prevent it being expanded as an alias. Finally, you can use the ksh function definition syntax: function abcd { echo xyz; } which doesn't expand the function name as an alias. -zefram