bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Just created alias doesn't work in a string of commands


From: Paul Jarc
Subject: Re: Just created alias doesn't work in a string of commands
Date: Thu, 08 Feb 2007 11:50:29 -0500
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux)

"Gurjeet Singh" <singh.gurjeet@gmail.com> wrote:
> 1$ cat setenv.sh
> #!/bin/sh
>
> alias llrt='ls -lrt'
...
> 5$ . ./setenv.sh && llrt && . ./unsetenv.sh
> sh: llrt: command not found

Aliases are expanded when a command is read, not when it is executed.
The entire && chain of commands forms a single compound command, which
is completely read before any of it is executed, so the alias is not
defined yet at the point when it would be expanded.


paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]