From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Marc Chantreux <khatar@phear.org>
Cc: zsh-users@zsh.org
Subject: Re: make aliases work inside the function? (using a preprocessor?)
Date: Wed, 04 May 2016 16:55:41 +0200 [thread overview]
Message-ID: <1209.1462373741@thecus.kiddle.eu> (raw)
In-Reply-To: <20160504134632.GA5729@aurora-borealis.phear.org>
Marc Chantreux wrote:
>
> I have
>
> % which €
> € () {
> setopt localoptions unset nowarncreateglobal
> "$@" }
> % which l
> l: aliased to print -l
> % € l error
> €: command not found: l
You could also try using:
alias €='€ '
This doesn't enable alias expansion inside the function if that is
exactly what you need. But it does work for the example above: the
trailing space in the alias indicates that the next word is treated as
being in command position for alias expansion so l will be expanded
already outside the function.
It's quite common to use this with precommands, for example:
for com in command builtin time nice - nocorrect exec rusage noglob eval nohup;
alias -- $com="$com "
Oliver
next prev parent reply other threads:[~2016-05-04 15:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-04 13:46 Marc Chantreux
2016-05-04 14:04 ` Peter Stephenson
2016-05-04 14:55 ` Oliver Kiddle [this message]
2016-05-04 17:21 ` Bart Schaefer
2016-05-09 12:30 ` Marc Chantreux
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=1209.1462373741@thecus.kiddle.eu \
--to=okiddle@yahoo.co.uk \
--cc=khatar@phear.org \
--cc=zsh-users@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).