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

Re: odd recursion

On Jan 31,  8:24am, William Scott wrote:
} 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.

You stumbled on FAQ question number 2.3, "Why do my csh aliases not work?
(Plus other alias pitfalls.)"

  There is one other serious problem with aliases: consider

    alias l='/bin/ls -F'
    l() { /bin/ls -la "$@" | more }

  `l' in the function definition is in command position and is expanded
  as an alias, defining `/bin/ls' and `-F' as functions which call
  `/bin/ls', which gets a bit recursive.  This can be avoided if you use
  `function' to define a function, which doesn't expand aliases.  It is
  possible to argue for extra warnings somewhere in this mess.

  Bart Schaefer's rule is:  Define first those aliases you expect to
  use in the body of a function, but define the function first if the
  alias has the same name as the function.

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