From 9575f2f1bf404b90002a5a55e13558288152a105 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 24 Jun 2020 10:40:45 +0000 Subject: users/24959/0002: Update aliases documentation for the addition of the ALIAS_FUNC_DEF option. --- Doc/Zsh/grammar.yo | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'Doc') diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo index 7eabd75ce..2eb2018d2 100644 --- a/Doc/Zsh/grammar.yo +++ b/Doc/Zsh/grammar.yo @@ -571,6 +571,11 @@ position (if it could be the first word of a simple command), or if the alias is global. If the replacement text ends with a space, the next word in the shell input is always eligible for purposes of alias expansion. + +It is an error for the function name, var(word), in the sh-compatible function +definition syntax `var(word) tt(+LPAR()+RPAR()) ...' to be a word that resulted +from alias expansion, unless the tt(ALIAS_FUNC_DEF) option is set. + findex(alias, use of) cindex(aliases, global) An alias is defined using the tt(alias) builtin; global aliases @@ -656,26 +661,6 @@ a problem in shell scripts, functions, and code executed with `tt(source)' or `tt(.)'. Consequently, use of functions rather than aliases is recommended in non-interactive code. -Note also the unhelpful interaction of aliases and function definitions: - -example(alias func='noglob func' -func+LPAR()RPAR() { - echo Do something with $* -}) - -Because aliases are expanded in function definitions, this causes the -following command to be executed: - -example(noglob func+LPAR()RPAR() { - echo Do something with $* -}) - -which defines tt(noglob) as well as tt(func) as functions with the -body given. To avoid this, either quote the name tt(func) or use the -alternative function definition form `tt(function func)'. Ensuring the -alias is defined after the function works but is problematic if the -code fragment might be re-executed. - texinode(Quoting)()(Aliasing)(Shell Grammar) sect(Quoting) cindex(quoting) -- cgit 1.4.1