Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: alias/anon_function quoting issue
- X-seq: zsh-users 29116
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Johan Grande <nahoj@xxxxxxxxx>
- Cc: linuxtechguy@xxxxxxxxx, zsh <zsh-users@xxxxxxx>
- Subject: Re: alias/anon_function quoting issue
- Date: Fri, 28 Jul 2023 14:53:52 -0700
- Archived-at: <https://zsh.org/users/29116>
- In-reply-to: <94d698df-95f6-5d42-0402-5b46b7152463@crans.org>
- List-id: <zsh-users.zsh.org>
- References: <CA+rB6GJ_opAWNCCBbQC=KQLwvYpjJ2Z6SK+yNjXqpuYyfKN+aw@mail.gmail.com> <94d698df-95f6-5d42-0402-5b46b7152463@crans.org>
On Thu, Jul 27, 2023 at 1:51 AM Johan Grande <nahoj@xxxxxxxxx> wrote:
>
> Le 14/07/2023 à 16:46, Jim a écrit :
> >
> > alias name='(){ ... }'
>
> Hi, I'm curious, is there a particular advantage to doing this rather
> than declaring a function?
I can think of only a couple.
First, you can define a suffix alias this way:
alias -s tgz='() { tar -tzf - < $1 }'
Second, with an alias you can use simple quoting to switch back to a
command of the same name. In this example:
vim() { gvim "$@" }
\vim foo
the "vim" function is still executed and you get gvim. But with this:
alias vim='() { gvim "$@" }'
\vim foo
the alias is not expanded and /bin/vim runs directly.
If there are other reasons they don't occur to me offhand.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author