[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Issues when func name is the same with an alias
From: |
Clark J. Wang |
Subject: |
Re: Issues when func name is the same with an alias |
Date: |
Wed, 4 Aug 2010 22:38:59 +0800 |
On Wed, Aug 4, 2010 at 8:27 PM, Bernd Eggink <monoped@sudrala.de> wrote:
> Am 04.08.2010 12:39, schrieb Clark J. Wang:
>
> I was testing the precedence between functions and aliases so I tried like
>> this (with bash 4.1.5):
>>
>> $ cat rc
>> alias foo='echo this is the alias'
>>
>> foo()
>> {
>> builtin echo 'this is the function'
>> }
>>
>> foo
>> $ source rc
>> bash: confusing-aliases-2.sh: line 4: syntax error near unexpected token
>> `('
>> bash: confusing-aliases-2.sh: line 4: `foo()'
>> $
>>
>> Seems like I must explicitly use the `function' keyword to define foo()
>> for
>> this scenario. Is that the correct behavior?
>>
>
> The man page says "The first word of a simple command, if unquoted, is
> checked to see if has an alias". Therefore 'foo' in your function
> declaration is replaced by 'echo this is the alias'. Unfortunately, you
> can't quote the function name in the declaration, so you have to either use
> 'function' or say "unalias foo" first.
>
> Function definitions are not simple commands. Actually, func definition
syntax is listed under the *Compound Commands* section in bash2.05b's man
page and in bash3+ it's been moved to a separate section.
> Regards,
> Bernd
>
> --
> Bernd Eggink
> http://sudrala.de
>
>
- Re: Issues when func name is the same with an alias, (continued)
- Re: Issues when func name is the same with an alias, Marc Herbert, 2010/08/04
- Re: Issues when func name is the same with an alias, Eric Blake, 2010/08/04
- Re: Issues when func name is the same with an alias, Clark J. Wang, 2010/08/04
- Re: Issues when func name is the same with an alias, Marc Herbert, 2010/08/05
- Re: Issues when func name is the same with an alias, Clark J. Wang, 2010/08/05
- Re: Issues when func name is the same with an alias, Chris F.A. Johnson, 2010/08/05
- Re: Issues when func name is the same with an alias, Clark J. Wang, 2010/08/05
- Re: Issues when func name is the same with an alias, Marc Herbert, 2010/08/06
Re: Issues when func name is the same with an alias, Bernd Eggink, 2010/08/04
- Re: Issues when func name is the same with an alias,
Clark J. Wang <=