Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: odd recursion
- X-seq: zsh-users 8441
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: William Scott <wgscott@xxxxxxxxxxxxxxxxxx>, L:ZSH-users <zsh-users@xxxxxxxxxx>
- Subject: Re: odd recursion
- Date: Mon, 31 Jan 2005 16:46:32 +0000
- In-reply-to: <5ced8dfb84fe26e20350095da48dd44d@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <5ced8dfb84fe26e20350095da48dd44d@xxxxxxxxxxxxxxxxxx>
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