Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

recursive function warnings ...

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 $*
    finger ${*}@ucc

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

Of course something like:

function finger {
  if [[ $* == "*@*" ]] then
    /usr/bin/finger $*
    /usr/bin/finger ${*}@ucc

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@xxxxxxx then it'll not finger ucc.

Messages sorted by: Reverse Date, Date, Thread, Author