Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: global alias with leading space gives unexpected thing



On 27 April 2010 23:41, Dmitry Bolshakov <bdimych@xxxxxxxx> 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



Messages sorted by: Reverse Date, Date, Thread, Author