zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <zefram@dcs.warwick.ac.uk>
To: morgan@usf.teradyne.com (Brady Morgan)
Cc: zsh-workers@math.gatech.edu
Subject: Re: Problem with alias in 'if' blocks
Date: Sat, 4 Jan 1997 19:51:14 +0000 (GMT)	[thread overview]
Message-ID: <3834.199701041951@stone.dcs.warwick.ac.uk> (raw)
In-Reply-To: <9701040144.AA16789@tachyon.usf.teradyne.com> 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


      reply	other threads:[~1997-01-04 19:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-04  1:44 Brady Morgan
1997-01-04 19:51 ` Zefram [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3834.199701041951@stone.dcs.warwick.ac.uk \
    --to=zefram@dcs.warwick.ac.uk \
    --cc=morgan@usf.teradyne.com \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).