Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [Zsh bug] function define bug



On Tue, Nov 24, 2015 at 9:46 PM, Ngô Huy <huynhok.uit@xxxxxxxxx> wrote:
> Dear folks,
>
> I found the problem in zsh define function. Demo
>
> ls test() { echo "Bug !!!"} && ls && test
>
> it will print
>
> Bug !!!
> Bug !!!


That's expected behaviour. Since MULTI_FUNC_DEF is set by default in zsh
mode, both ls and test are being defined as functions with the body
echo "Bug !!!".

% func1 func2 () { echo This is "$0"; }
% func1; func2
This is func1
This is func2
% which func{1,2}
func1 () {
        echo This is "$0"
}
func2 () {
        echo This is "$0"
}
% unsetopt MULTI_FUNC_DEF
% func1 func2 () { echo This is "$0"; }
zsh: parse error near `()'



Messages sorted by: Reverse Date, Date, Thread, Author