1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-22 16:20:23 +02:00

users/24959/0002: Update aliases documentation for the addition of the ALIAS_FUNC_DEF option.

This commit is contained in:
Daniel Shahaf 2020-06-24 10:40:45 +00:00
parent 7f58463dd3
commit 9575f2f1bf
2 changed files with 8 additions and 20 deletions

View file

@ -1,5 +1,8 @@
2020-06-27 Daniel Shahaf <d.s@daniel.shahaf.name> 2020-06-27 Daniel Shahaf <d.s@daniel.shahaf.name>
* users/24959/0002: Doc/Zsh/grammar.yo: Update aliases
documentation for the addition of the ALIAS_FUNC_DEF option.
* users/24959/0001: Doc/Zsh/builtins.yo, Doc/Zsh/grammar.yo: * users/24959/0001: Doc/Zsh/builtins.yo, Doc/Zsh/grammar.yo:
Extend documentation of global aliases. Extend documentation of global aliases.

View file

@ -571,6 +571,11 @@ position (if it could be the first word of a simple command),
or if the alias is global. or if the alias is global.
If the replacement text ends with a space, the next word in the shell input If the replacement text ends with a space, the next word in the shell input
is always eligible for purposes of alias expansion. 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) findex(alias, use of)
cindex(aliases, global) cindex(aliases, global)
An alias is defined using the tt(alias) builtin; global aliases 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 or `tt(.)'. Consequently, use of functions rather than aliases is
recommended in non-interactive code. 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) texinode(Quoting)()(Aliasing)(Shell Grammar)
sect(Quoting) sect(Quoting)
cindex(quoting) cindex(quoting)