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

Re: Do local functions exist in Zsh?



In my tests, Zsh 5.9 accepts "local foo() { : }" as valid syntax.
Is this syntax intentional?

No, I'm afraid that's not doing what you want. It's defining both
local and foo as equivalent names for the same function.

This is documented, but it's admittedly easy to overlook, especially
if you're not reading closely.

	function [ -T ] WORD ... [ () ] [ TERM ] { LIST }
	WORD ... () [ TERM ] { LIST }
	WORD ... () [ TERM ] COMMAND

I even added support for multiple names already, but when I saw the "local" I was confused and didn't think about alias names. "local" as an additional name, even though it's a reserved word, explains it.

Thanks all for your help!

Joachim
--
BashSupport Pro
https://www.bashsupport.com/





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