[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: alias vs unalias
From: |
Chet Ramey |
Subject: |
Re: alias vs unalias |
Date: |
Tue, 17 Dec 2002 09:00:21 -0500 |
> I have found a difference in the handling of "alias" vs "unalias" and believe
> this
> is a bug (if it isn't, would someone please mail me as to why). Here's my
> finding:
Doesn't anyone read the documentation anymore? From bash.1:
The rules concerning the definition and use of aliases are
somewhat confusing. Bash always reads at least one com-
plete line of input before executing any of the commands
on that line. Aliases are expanded when a command is
read, not when it is executed. Therefore, an alias defi-
nition appearing on the same line as another command does
not take effect until the next line of input is read. The
commands following the alias definition on that line are
not affected by the new alias. This behavior is also an
issue when functions are executed. Aliases are expanded
when a function definition is read, not when the function
is executed, because a function definition is itself a
compound command. As a consequence, aliases defined in a
function are not available until after that function is
executed. To be safe, always put alias definitions on a
separate line, and do not use alias in compound commands.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Chet Ramey, ITS, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/