From: Peter Stephenson <Peter.Stephenson@csr.com>
To: zsh-workers@zsh.org
Subject: PATCH: document more alias problems
Date: Wed, 27 Oct 2010 13:49:00 +0100 [thread overview]
Message-ID: <20101027134900.48001ac2@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <87k4l34yfb.fsf@gmail.com>
While I'm at it, it's probably high time that another note on alias
problems was promoted to the manual. It's been in the FAQ for a while
but it could do with highlighting since it's really annoying and
confusing if you come across it.
Index: Doc/Zsh/grammar.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/grammar.yo,v
retrieving revision 1.20
diff -p -u -r1.20 grammar.yo
--- Doc/Zsh/grammar.yo 27 Oct 2010 12:29:13 -0000 1.20
+++ Doc/Zsh/grammar.yo 27 Oct 2010 12:45:19 -0000
@@ -500,6 +500,27 @@ is too late to expand the newly defined
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)
--
Peter Stephenson <pws@csr.com> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
next prev parent reply other threads:[~2010-10-27 12:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-20 11:28 Prefixed backslash removed when completing command Mikael Auno
2010-05-20 12:39 ` Peter Stephenson
2010-10-27 9:06 ` Mikael Auno
2010-10-27 10:02 ` Peter Stephenson
2010-10-27 10:41 ` Mikael Auno
2010-10-27 10:48 ` Peter Stephenson
2010-10-27 12:23 ` Štěpán Němec
2010-10-27 12:29 ` Mikael Magnusson
2010-10-27 12:49 ` Peter Stephenson [this message]
2010-10-27 10:49 ` Mikael Magnusson
2010-10-27 15:43 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101027134900.48001ac2@pwslap01u.europe.root.pri \
--to=peter.stephenson@csr.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).