From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@sunsite.dk
Subject: Re: Bug#537596: regression: parse error near `()' in function definition
Date: Mon, 20 Jul 2009 11:10:47 +0200 [thread overview]
Message-ID: <237967ef0907200210k1df76e67u16056ff1e5d1be27@mail.gmail.com> (raw)
In-Reply-To: <200907200850.n6K8ovIg028836@news01.csr.com>
2009/7/20 Peter Stephenson <pws@csr.com>:
> Mikael Magnusson wrote:
>> Just thought I'd mention you can also use \ at any time to escape an alias:
>
> Something like that is worth mentioning.
>
> Index: Etc/FAQ.yo
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Etc/FAQ.yo,v
> retrieving revision 1.47
> diff -u -r1.47 FAQ.yo
> --- Etc/FAQ.yo 21 Apr 2009 09:33:37 -0000 1.47
> +++ Etc/FAQ.yo 20 Jul 2009 08:50:23 -0000
> @@ -819,6 +819,14 @@
> use in the body of a function, but define the function first if the
> alias has the same name as the function.
>
> + If you aware of the problem, you can always escape part or all of the
> + name of the function:
> + verb(
> + 'l'() { /bin/ls -la "$@" | more }
> + )
> + Adding the quotes has no effect on the function definition, but
> + suppresses alias expansion for the function name. Hence this is
> + guaranteed to be safe.
I didn't look up more of the context than what is in the diff hunk, so
maybe this guarantee only holds for aliases of l, but not generally:
% alias l='echo hello'
% alias \'l\'='echo bye'
% l
hello
% 'l'
bye
% 'l'() {print i am a function}
% l
i am a function
% 'l'
i am a function
% "'l'"
zsh: command not found: 'l'
% which l
l: aliased to echo hello
% which 'l'
l: aliased to echo hello
% which "'l'"
'l': aliased to echo bye
What happened at this point:
% 'l'() {print i am a function}
was of course that i defined "echo" (and "bye"):
% which echo
echo () {
print i am a function
}
--
Mikael Magnusson
next prev parent reply other threads:[~2009-07-20 9:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090719171651.GA7217@piper.oerlikon.madduck.net>
2009-07-19 23:20 ` Clint Adams
2009-07-20 4:18 ` Bart Schaefer
2009-07-20 8:27 ` Peter Stephenson
2009-07-20 8:37 ` Mikael Magnusson
2009-07-20 8:50 ` Peter Stephenson
2009-07-20 9:10 ` Mikael Magnusson [this message]
2009-07-20 9:15 ` Peter Stephenson
2009-07-20 8:46 ` martin f krafft
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=237967ef0907200210k1df76e67u16056ff1e5d1be27@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@sunsite.dk \
/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).