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

odd recursion



Hi Everyone:

I stumbled onto something that makes me realize there is a lot to zsh I don't understand. I've resolved the problem, but I still don't understand it.

The problem comes about if I first define an alias for a command and then a posix function for the same command. Issuing the command after doing this results in a recursion and my system freezes up if I am not quick with the control-C key. I am using zsh on OS X v. 10.3. This happens at least with zsh v. 4.1.1 and the current 4.2.3.

Just to be sure, I issue these commands first:

unalias ls
unalias lf
unfunction ls
unfunction lf

alias lf='command ls -Fa'
lf () {
        command ls --color=auto -lh ${*} | egrep "^d"
        command ls --color=auto -lh $* 2>& - | egrep -v "^d|total "
}

Then use lf.

It looks like some sort of recursion happens, even though I don't see logically what it is, and I have prefixed ls with "command" in each case.

The ONLY cure I found (apart from not doing this) is to use

function lf { commands }



syntax instead of posix syntax.  Then it all works.

The bash to zsh book gave me the impression that the two syntaxes are now equivalent. Clearly that impression is wrong.

Thanks for any insights.

Bill




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