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

Re: Bug#537596: regression: parse error near `()' in function definition



2009/7/20 Peter Stephenson <pws@xxxxxxx>:
> Mikael Magnusson wrote:
>> Just thought I'd mention you can also use \ at any time to escape an alias:
>
> Something like that is worth mentioning.
>
> Index: Etc/FAQ.yo
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Etc/FAQ.yo,v
> retrieving revision 1.47
> diff -u -r1.47 FAQ.yo
> --- Etc/FAQ.yo  21 Apr 2009 09:33:37 -0000      1.47
> +++ Etc/FAQ.yo  20 Jul 2009 08:50:23 -0000
> @@ -819,6 +819,14 @@
>   use in the body of a function, but define the function first if the
>   alias has the same name as the function.
>
> +  If you aware of the problem, you can always escape part or all of the
> +  name of the function:
> +  verb(
> +     'l'() { /bin/ls -la "$@" | more }
> +  )
> +  Adding the quotes has no effect on the function definition, but
> +  suppresses alias expansion for the function name.  Hence this is
> +  guaranteed to be safe.

I didn't look up more of the context than what is in the diff hunk, so
maybe this guarantee only holds for aliases of l, but not generally:
% alias l='echo hello'
% alias \'l\'='echo bye'
% l
hello
% 'l'
bye
% 'l'() {print i am a function}
% l
i am a function
% 'l'
i am a function
% "'l'"
zsh: command not found: 'l'
% which l
l: aliased to echo hello
% which 'l'
l: aliased to echo hello
% which "'l'"
'l': aliased to echo bye

What happened at this point:
% 'l'() {print i am a function}

was of course that i defined "echo" (and "bye"):
% which echo
echo () {
	print i am a function
}

-- 
Mikael Magnusson



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