From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19738 invoked from network); 6 Jun 2005 15:37:00 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 Jun 2005 15:37:00 -0000 Received: (qmail 61174 invoked from network); 6 Jun 2005 15:36:53 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Jun 2005 15:36:53 -0000 Received: (qmail 22217 invoked by alias); 6 Jun 2005 15:36:43 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8961 Received: (qmail 22207 invoked from network); 6 Jun 2005 15:36:42 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 6 Jun 2005 15:36:42 -0000 Received: (qmail 60112 invoked from network); 6 Jun 2005 15:36:42 -0000 Received: from p54852e8c.dip0.t-ipconnect.de (HELO solfire) (84.133.46.140) by a.mx.sunsite.dk with SMTP; 6 Jun 2005 15:36:37 -0000 Received: from localhost ([127.0.0.1]) by solfire with esmtp (Exim 4.42) id 1DfJfN-00061j-IO; Mon, 06 Jun 2005 17:37:32 +0200 Date: Mon, 06 Jun 2005 17:37:29 +0200 (CEST) Message-Id: <20050606.173729.74747423.Meino.Cramer@gmx.de> To: schaefer@brasslantern.com Cc: zsh-users@sunsite.dk From: Meino Christian Cramer In-Reply-To: <1050606041449.ZM21454@candle.brasslantern.com> References: <20050606.052350.41178724.Meino.Cramer@gmx.de> <1050606041449.ZM21454@candle.brasslantern.com> X-Mailer: Mew version 4.1 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Rcpt-To: schaefer@brasslantern.com, zsh-users@sunsite.dk X-SA-Exim-Mail-From: Meino.Cramer@gmx.de Subject: Re: Function definitions Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SA-Exim-Version: 4.1+cvs (built Sat, 28 Aug 2004 13:10:40 +0200) X-SA-Exim-Scanned: Yes (on solfire) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-0.5 required=6.0 tests=BAYES_00,RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL autolearn=no version=3.0.2 X-Spam-Hits: -0.5 From: Bart Schaefer Subject: Re: Function definitions Date: Mon, 06 Jun 2005 04:14:49 +0000 Hi Bart ! THANKS a LOT for that enlightment ! :) Far better than what I saw (but not understood in that extent as you have explained it!!!). With "I found nothing appropiate" I meant exactly this! I _saw_ words from that context...but...I _understood_ what Bart wrotes!!! :O) Keep zshing! (<<- that words reminds me of the sound of opening a bottle fresh beer...;) Meino > On Jun 6, 5:23am, Meino Christian Cramer wrote: > > > > Is there any difference in defining functions like > > In zsh there is no difference whether you use the "function" keyword or > not, but in ksh the variable scoping rules are different for definitions > that use it. So be careful if you have any intention of porting. > > I prefer to use "function" because it avoids problems with function and > alias names clashing. > > However: > > > function fnord(){ > > fnord(){ > > Those two are OK and do what you expect, but you should get used to > putting spaces before the empty parens and before the open-brace, because > even though zsh does not always enforce it, the grammar does say that the > spaces should be there, and it's crucial to this next example: > > > function fnord{ > > That defines a function named "fnord{" whose body will consist of the next > single command seen (*not* up to a matching close-brace). If you add a > space ... > > function fnord { > > ... then *that* does what you meant. > > > fnord{ > > This is a *call* to the function named "fnord{". Even with a space ... > > fnord { > > ... is not a definition, it's a *call* to the "fnord" function with the > argument "{". You must have either the keyword "function" or the empty > parens to make a definition. I believe using both is a syntax error in > ksh, although zsh allows it. > > > (In 'man zshall' I found nothing appropiate...) > > In the COMPLEX COMMANDS section: > > function word ... [ () ] [ term ] { list } > word ... () [ term ] { list } > word ... () [ term ] command > where term is one or more newline or ;. Define a function > which is referenced by any one of word. >