diff options
author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2020-06-24 10:40:45 +0000 |
---|---|---|
committer | Daniel Shahaf <d.s@daniel.shahaf.name> | 2020-06-27 00:53:02 +0000 |
commit | 9575f2f1bf404b90002a5a55e13558288152a105 (patch) | |
tree | 5f6cd2312e1140d997822b1c637827a25eec38ba /Doc | |
parent | 7f58463dd33cfd75af894ba30fcbda576c112e46 (diff) | |
download | zsh-9575f2f1bf404b90002a5a55e13558288152a105.tar.gz zsh-9575f2f1bf404b90002a5a55e13558288152a105.tar.xz zsh-9575f2f1bf404b90002a5a55e13558288152a105.zip |
users/24959/0002: Update aliases documentation for the addition of the ALIAS_FUNC_DEF option.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/Zsh/grammar.yo | 25 |
1 files changed, 5 insertions, 20 deletions
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) |