Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Problem with alias in 'if' blocks
- X-seq: zsh-workers 2723
- From: Zefram <zefram@xxxxxxxxxxxxxxxxx>
- To: morgan@xxxxxxxxxxxxxxxx (Brady Morgan)
- Subject: Re: Problem with alias in 'if' blocks
- Date: Sat, 4 Jan 1997 19:51:14 +0000 (GMT)
- Cc: zsh-workers@xxxxxxxxxxxxxxx
- In-reply-to: <9701040144.AA16789@xxxxxxxxxxxxxxxxxxxxxxxx> from "Brady Morgan" at Jan 3, 97 05:44:11 pm
Brady Morgan wrote:
>Can someone explain why the alias isn't "known" until I'm out of the
>"if" loop? Also, if I've goofed with this, could someone demonstrate
>the proper way to achieve the desired result.
Aliases are expanded when commands are first scanned, not when they are
executed. The entire if construct has to be read in and parsed before
it can be executed at all, so the aliases expanded in it are those in
effect at the start of the construct.
The solution is to use a shell function, rather than an alias. The
behaviour of functions is better defined, and more like normal
commands. Aliases are really only useful interactively.
-zefram
Messages sorted by:
Reverse Date,
Date,
Thread,
Author