From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18885 invoked from network); 1 Feb 2005 02:50:17 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 1 Feb 2005 02:50:17 -0000 Received: (qmail 6552 invoked from network); 1 Feb 2005 02:50:11 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Feb 2005 02:50:11 -0000 Received: (qmail 22111 invoked by alias); 1 Feb 2005 02:49:54 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8448 Received: (qmail 22098 invoked from network); 1 Feb 2005 02:49:53 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 1 Feb 2005 02:49:53 -0000 Received: (qmail 5125 invoked from network); 1 Feb 2005 02:49:17 -0000 Received: from out001pub.verizon.net (HELO out001.verizon.net) (206.46.170.140) by a.mx.sunsite.dk with SMTP; 1 Feb 2005 02:49:10 -0000 Received: from candle.brasslantern.com ([4.11.10.129]) by out001.verizon.net (InterMail vM.5.01.06.06 201-253-122-130-106-20030910) with ESMTP id <20050201024834.CDTM3126.out001.verizon.net@candle.brasslantern.com> for ; Mon, 31 Jan 2005 20:48:34 -0600 Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j112mS2j031994 for ; Mon, 31 Jan 2005 18:48:28 -0800 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j112mSfi031993 for zsh-users@sunsite.dk; Mon, 31 Jan 2005 18:48:28 -0800 From: Bart Schaefer Message-Id: <1050201024828.ZM31992@candle.brasslantern.com> Date: Tue, 1 Feb 2005 02:48:28 +0000 In-Reply-To: <07053ae70a0e029b3df8b8431dfa6243@chemistry.ucsc.edu> Comments: In reply to William Scott "Re: odd recursion" (Jan 31, 3:30pm) References: <5ced8dfb84fe26e20350095da48dd44d@chemistry.ucsc.edu> <1ba5918552xff.dlg@thorstenkampe.de> <6f5f1b5c88ce1d0196392e62bcf981f1@chemistry.ucsc.edu> <41FE98A3.8040700@cql.com> <07053ae70a0e029b3df8b8431dfa6243@chemistry.ucsc.edu> X-Mailer: Z-Mail (5.0.0 30July97) To: L:ZSH-users Subject: Re: odd recursion MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Authentication-Info: Submitted using SMTP AUTH at out001.verizon.net from [4.11.10.129] at Mon, 31 Jan 2005 20:48:30 -0600 X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Jan 31, 3:30pm, William Scott wrote: } } The main point of the question was that I don't see how/why it is a } recursion, from the logic of the expressions, which is why I said } there was some sort of fundamental gap in my understanding of how zsh } works. There are two bits to this, both of which were touched on in the FAQ snippet I posted but not really spelled out in detail. First, the function syntax is not (as you might expect) name () { body } Rather, it's name1 name2 name3 ... () { body } where name2 name3 ... are optional Thus it's possible to create a whole set of identical functions in a single pass. The obscure reason that this is useful is that, when you setopt FUNCTION_ARGZERO, you can actually have the same function behave differently depending on its name, just as is sometimes done with C programs and argv[0]. Second, alias expansion applies to any word in the "command position" on a command line, BEFORE that command line is parsed. (Global aliases are another thing entirely.) In the expression name () { body } the word "name" is in the command position. Thus the statements alias name='name arguments' name () { body } are equivalent to the single statement name arguments () { body } which, depending on the exact statements in "body", might recursively reference "name" yet again.