* Alias named '='
@ 2017-10-08 8:03 René Neumann
2017-10-08 8:29 ` Vincent Bernat
0 siblings, 1 reply; 5+ messages in thread
From: René Neumann @ 2017-10-08 8:03 UTC (permalink / raw)
To: Zsh Users
Hi all,
I stumbled upon the idea to define a function '=' to have an inline
calculator in zsh [1].
As multiplication is a normal operation, I also want 'noglob' behavior.
There seems to be no way of defining this for a function (or is there?),
so the only way would be to haven an alias
alias '='='noglob ='
But this seems to not be possible, yielding 'bad assignment': The alias
command seems to hard-parse until the first equal-sign -- even tricks like
alias $'\u3D'='noglob ='
do not work.
Does anyone know a trick that could be used here?
Best regards,
René
[1] https://github.com/arzzen/calc.plugin.zsh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Alias named '='
2017-10-08 8:03 Alias named '=' René Neumann
@ 2017-10-08 8:29 ` Vincent Bernat
2017-10-08 10:57 ` René Neumann
0 siblings, 1 reply; 5+ messages in thread
From: Vincent Bernat @ 2017-10-08 8:29 UTC (permalink / raw)
To: René Neumann; +Cc: Zsh Users
❦ 8 octobre 2017 10:03 +0200, René Neumann <lists@necoro.eu> :
> I stumbled upon the idea to define a function '=' to have an inline
> calculator in zsh [1].
>
> As multiplication is a normal operation, I also want 'noglob' behavior.
> There seems to be no way of defining this for a function (or is there?),
> so the only way would be to haven an alias
> alias '='='noglob ='
>
> But this seems to not be possible, yielding 'bad assignment': The alias
> command seems to hard-parse until the first equal-sign -- even tricks like
> alias $'\u3D'='noglob ='
> do not work.
I am using "c" instead of "=", but you can use "=" with:
aliases[=]='noglob ='
--
Use the "telephone test" for readability.
- The Elements of Programming Style (Kernighan & Plauger)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Alias named '='
2017-10-08 8:29 ` Vincent Bernat
@ 2017-10-08 10:57 ` René Neumann
2017-10-08 18:37 ` Daniel Shahaf
0 siblings, 1 reply; 5+ messages in thread
From: René Neumann @ 2017-10-08 10:57 UTC (permalink / raw)
To: Vincent Bernat; +Cc: Zsh Users
Am 08.10.2017 um 10:29 schrieb Vincent Bernat:
> ❦ 8 octobre 2017 10:03 +0200, René Neumann <lists@necoro.eu> :
>
>> I stumbled upon the idea to define a function '=' to have an inline
>> calculator in zsh [1].
>>
>> As multiplication is a normal operation, I also want 'noglob' behavior.
>> There seems to be no way of defining this for a function (or is there?),
>> so the only way would be to haven an alias
>> alias '='='noglob ='
>>
>> But this seems to not be possible, yielding 'bad assignment': The alias
>> command seems to hard-parse until the first equal-sign -- even tricks like
>> alias $'\u3D'='noglob ='
>> do not work.
>
> I am using "c" instead of "=", but you can use "=" with:
>
> aliases[=]='noglob ='
>
Ah, thanks! That worked.
- René
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Alias named '='
2017-10-08 10:57 ` René Neumann
@ 2017-10-08 18:37 ` Daniel Shahaf
2017-10-08 22:37 ` Ray Andrews
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Shahaf @ 2017-10-08 18:37 UTC (permalink / raw)
To: René Neumann; +Cc: Vincent Bernat, Zsh Users
René Neumann wrote on Sun, Oct 08, 2017 at 12:57:43 +0200:
> Am 08.10.2017 um 10:29 schrieb Vincent Bernat:
> > I am using "c" instead of "=", but you can use "=" with:
> >
> > aliases[=]='noglob ='
> >
>
> Ah, thanks! That worked.
It did, but setting aliases this way not supported:
% aliases[=]='echo foo'
% alias -L >/dev/null
zsh: invalid alias '=' encountered while printing aliases
%
Context: http://www.zsh.org/cgi-bin/mla/redirect?WORKERNUMBER=37548
Suggest that you use something other than '=' as the first character.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Alias named '='
2017-10-08 18:37 ` Daniel Shahaf
@ 2017-10-08 22:37 ` Ray Andrews
0 siblings, 0 replies; 5+ messages in thread
From: Ray Andrews @ 2017-10-08 22:37 UTC (permalink / raw)
To: zsh-users
On 08/10/17 11:37 AM, Daniel Shahaf wrote:
>
> Suggest that you use something other than '=' as the first character.
Yeah, it astonishes me that such a thing would even be attempted or that
it could possibly work anyway. There must be characters that are
preserved for symbolic use only.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-08 23:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-08 8:03 Alias named '=' René Neumann
2017-10-08 8:29 ` Vincent Bernat
2017-10-08 10:57 ` René Neumann
2017-10-08 18:37 ` Daniel Shahaf
2017-10-08 22:37 ` Ray Andrews
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).