zsh-workers
 help / color / mirror / code / Atom feed
* global alias with leading space gives unexpected thing
@ 2010-04-27 21:41 Dmitry Bolshakov
  2010-04-27 22:02 ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Bolshakov @ 2010-04-27 21:41 UTC (permalink / raw)
  To: zsh-workers

hi
there it is, copy-paste this into the shell

====================================================
setopt histignorespace



: ---------- if there is leading space in the alias
alias -g X=' >/dev/null'
true X
history -1
: ---------- then the command with the alias is absent in the history



: ---------- if no leading space
alias -g X='>/dev/null'
true X
history -1
: ---------- then the command is present



: ---------- if leading space, but the histignorespace is off
alias -g X=' >/dev/null'
setopt no_histignorespace
true X
history -1
: ---------- then also present

====================================================
 

this seems strange a bit for me
i always imagined that a count of spaces does not matter

all

somecommand >/dev/null
somecommand  >/dev/null
somecommand   >/dev/null

are the same, isn't it so?


-- 
with best regards
Dmitry Bolshakov


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: global alias with leading space gives unexpected thing
  2010-04-27 21:41 global alias with leading space gives unexpected thing Dmitry Bolshakov
@ 2010-04-27 22:02 ` Mikael Magnusson
  2010-04-28  8:56   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2010-04-27 22:02 UTC (permalink / raw)
  To: Dmitry Bolshakov; +Cc: zsh-workers

On 27 April 2010 23:41, Dmitry Bolshakov <bdimych@narod.ru> wrote:
> hi
> there it is, copy-paste this into the shell
>
> ====================================================
> setopt histignorespace
>
>
>
> : ---------- if there is leading space in the alias
> alias -g X=' >/dev/null'
> true X
> history -1
> : ---------- then the command with the alias is absent in the history
>
>
>
> : ---------- if no leading space
> alias -g X='>/dev/null'
> true X
> history -1
> : ---------- then the command is present
>
>
>
> : ---------- if leading space, but the histignorespace is off
> alias -g X=' >/dev/null'
> setopt no_histignorespace
> true X
> history -1
> : ---------- then also present
>
> ====================================================
>
>
> this seems strange a bit for me
> i always imagined that a count of spaces does not matter
>
> all
>
> somecommand >/dev/null
> somecommand  >/dev/null
> somecommand   >/dev/null
>
> are the same, isn't it so?
>
>
> --
> with best regards
> Dmitry Bolshakov
>

Maybe something like this is needed?

diff --git a/Src/lex.c b/Src/lex.c
index 8f43251..83257da 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1774,7 +1774,7 @@ exalias(void)
                if (an && !an->inuse &&
                    ((an->node.flags & ALIAS_GLOBAL) || incmdpos || inalmore)) {
                    inpush(an->text, INP_ALIAS, an);
-                   if (an->text[0] == ' ')
+                   if (an->text[0] == ' ' && !(an->node.flags & ALIAS_GLOBAL))
                        aliasspaceflag = 1;
                    lexstop = 0;
                    if (zshlextext == copy)


-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: global alias with leading space gives unexpected thing
  2010-04-27 22:02 ` Mikael Magnusson
@ 2010-04-28  8:56   ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2010-04-28  8:56 UTC (permalink / raw)
  To: zsh-workers

On Wed, 28 Apr 2010 00:02:00 +0200
Mikael Magnusson <mikachu@gmail.com> wrote:
> Maybe something like this is needed?
> 
> diff --git a/Src/lex.c b/Src/lex.c
> index 8f43251..83257da 100644
> --- a/Src/lex.c
> +++ b/Src/lex.c
> @@ -1774,7 +1774,7 @@ exalias(void)
>                 if (an && !an->inuse &&
>                     ((an->node.flags & ALIAS_GLOBAL) || incmdpos ||
> inalmore)) { inpush(an->text, INP_ALIAS, an);
> -                   if (an->text[0] == ' ')
> +                   if (an->text[0] == ' ' && !(an->node.flags &
> ALIAS_GLOBAL)) aliasspaceflag = 1;
>                     lexstop = 0;
>                     if (zshlextext == copy)

Yes, it's surely an oversight when it happens with global aliases.  I've
added this and noted it in the documentation.

-- 
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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-28  8:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-27 21:41 global alias with leading space gives unexpected thing Dmitry Bolshakov
2010-04-27 22:02 ` Mikael Magnusson
2010-04-28  8:56   ` Peter Stephenson

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).