summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-11-17 16:35:27 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-11-17 16:35:27 +0000
commit851b8e151004ec729dad9c8c7867bbf67649df8e (patch)
tree5170a88631283830e471463f31168413c7c1026b
parent7be8594c8cfea3fac39fa73cd5bcbae7e7f23477 (diff)
downloadzsh-851b8e151004ec729dad9c8c7867bbf67649df8e.tar.gz
zsh-851b8e151004ec729dad9c8c7867bbf67649df8e.tar.xz
zsh-851b8e151004ec729dad9c8c7867bbf67649df8e.zip
28377: document more alias problems
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/grammar.yo21
2 files changed, 26 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4e0aa500f..dd3873860 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-11-17  Peter Stephenson  <pws@csr.com>
+
+	* 28377: Doc/Zsh/grammar.yo: document more alias problems.
+
 2010-11-14  Clint Adams  <clint@zsh.org>
 
 	* 28411: Completion/Unix/Command/_git: complete submodule
@@ -13815,5 +13819,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5120 $
+* $Revision: 1.5121 $
 *****************************************************
diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo
index 27683fc70..5c803a681 100644
--- a/Doc/Zsh/grammar.yo
+++ b/Doc/Zsh/grammar.yo
@@ -500,6 +500,27 @@ is too late to expand the newly defined alias.  This is often
 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 defintions, 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)