From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id QAA01180 for ; Wed, 11 Sep 1996 16:49:43 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id CAA21064; Wed, 11 Sep 1996 02:39:07 -0400 (EDT) Resent-Date: Wed, 11 Sep 1996 02:39:07 -0400 (EDT) From: Duncan Sargeant Message-Id: <199609110637.OAA02883@mermaid.ucc.gu.uwa.edu.au> Subject: recursive function warnings ... To: zsh-workers@math.gatech.edu Date: Wed, 11 Sep 1996 14:37:09 +0800 (WST) X-Distribution: This message may not reproduce, be stored in a retrieval system, or transmit disease in any form without the permissiveness of the author. X-Mailer: ELM [version 2.4 PL25 PGP2] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"mHvpd1.0.295.AwbDo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2129 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu The one mistake I've made a few times now is that when I write a function to replace a command, and then call that command from within the function, I often get an error which usually means nothing to me, and its a while before I find out what I did wrong. Usually its because of something as in the following example: function finger { if [[ $* == "*@*" ]] then finger $* else finger ${*}@ucc fi } which recursively call the _function_ finger because I, cluelessly, have not specified a pathname (er derr). Looks easy to remember but its not the first time I've done it. And I doubt it'll be the last. Of course something like: function finger { if [[ $* == "*@*" ]] then /usr/bin/finger $* else /usr/bin/finger ${*}@ucc fi } is far more appropriate and what I wanted. anyway, I was just wondering about the possibility of an option or something so that if a function calls itself recursively, a warning message is printed, eg: Warning: function finger calls itself recursively. then maybe to stop this annoying message occurring again, one specifies the function with the -r option, eg function -r finger { ... just in case the function needs to call itself recursively. that would be really cool, if anyone can be bothered. -- Duncan Sargeant, http://www.ucc.gu.uwa.edu.au/~dunc/ The older a father gets, the farther he had to walk to school. PS: I'm not on zsh-workers myself ... only zsh-users, so I won't get any reply sent only to zsh-workers. PPS: why did I want such a function. Well the finger command on one machine in our domain is still the stock standard finger, whereas we use a global finger for all our machines, so that finger @ucc.gu.uwa.edu.au lists all users on all machines. Try it, if you like! anyway the function fingers @ucc if no @ is in the options. if @ is there eg foo@bar.net then it'll not finger ucc.