Re: your mail
On Tue, Feb 22, 2005 at 11:41:37AM -0800, Christopher Buckley wrote:
> Package: Bash
> Version: 2.03.0(1)
>
> But then
>
> root@server# set pat="anypath"
> root@server# t one two three
> testresults = pat=anypath one two three
>
> root@server# unset pat
> root@server# t one two three
> testresults = pat=anypath one two three
>
>
> Why is my last set command appearing as an argument???
The command "unset pat" deletes a variable named pat. In bash,
"set pat=anypath" does not create a "pat" variable, it creates a
parameter $1 which contains the string "pat=anypath".
>
> Finally, this doesn't appear to work either
>
> root@server# alias t='echo test results = $@ and thats it'
> root@server# t one two three
> testresults = and thats it one two three
>
>
> Why aren't the arguments appearing before the "and thats it" as they
> "should"?
>
If you wrote:
alias t='echo test results = '
t one two three
you would still get:
test results = one two three
The substitution of '$@' in the alias occurs before the line is executed.
Thus if you write:
set four five
alias t='echo test results = $@ and thats it'
t one two three
you would get:
testresults = four five and thats it one two three
For anything beyond simple substitution of a command name, you might
consider using a function instead of an alias.
Reply to: