From bb218704d27bcca9aa4426296dcd5c13d58b330a Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 10 Jan 2017 19:14:26 +0000 Subject: 40306 with doc tweaks: Change behaviour expanding alias in () function definition. Now an error unless the () is part of the same error as the name. Add ALIAS_FUNC_DEF option to allow it again. --- Doc/Zsh/options.yo | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'Doc/Zsh/options.yo') diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index f68a945ec..434b71094 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -1539,6 +1539,36 @@ enditem() subsect(Scripts and Functions) startitem() +pindex(ALIAS_FUNC_DEF) +pindex(NO_ALIAS_FUNC_DEF) +pindex(ALIASFUNCDEF) +pindex(NOALIASFUNCDEF) +cindex(functions, defining with expanded aliases) +cindex(aliases, expanding in function definition) +item(tt(ALIAS_FUNC_DEF) )( +By default, zsh does not allow the definition of functions using +the `var(name) tt(LPAR()RPAR())' syntax if var(name) was expanded as an +alias: this causes an error. This is usually the desired behaviour, as +otherwise the combination of an alias and a function based on the same +definition can easily cause problems. + +When this option is set, aliases can be used for defining functions. + +For example, consider the following definitions as they might +occur in a startup file. + +example(alias foo=bar +foo+LPAR()RPAR() { + print This probably does not do what you expect. +}) + +Here, tt(foo) is expanded as an alias to tt(bar) before the +tt(LPAR()RPAR()) is encountered, so the function defined would be named +tt(bar). By default this is instead an error in native mode. Note that +quoting any part of the function name, or using the keyword +tt(function), avoids the problem, so is recommended when the function +name can also be an alias. +) pindex(C_BASES) pindex(NO_C_BASES) pindex(CBASES) -- cgit 1.4.1