On Sun, 17 Nov 2024, Klemens Nanni wrote:
> 17.11.2024 22:00, Klemens Nanni пишет:
> > I can't say right away what the shell is supposed to do here and/or what it
> > really does;  looks like it expands the alias and before function 
> > definition.
> 
> That's what it does:
> 
>       $ alias foo=bar
>       $ foo() {}
>       $ typeset -f foo
>       $ typeset -f bar
>       bar() {}
> 
> So the original login='exec login' ends up as
> 
>       $ exec login() ...
>       sh: syntax error: `(' unexpected
> 
> It fails like that no matter what comes after (), which seems fair.
> 
> Now one could compare that behaviour with other shells, check standards
> and try argue, what (not) to do... I won't open that box of pandora myself ;)

It's the correct behavior: the name in the function definition syntax is 
in the position to be
   "parsed an the command name word of a simple command, based on
    this TOKEN and the tokens (if any) that preceded it, but ignoring
    whether any subsequent characters would allow that."

(XCU 2.3.1, Alias Substitution, p6)

So yes, the name in a function definition is subject to alias expansion 
when it meets the other requirements of that section (doesn't contain 
quoting characters, etc).

Reply via email to