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

Re: Bug in alias expansion

On Nov 18,  4:14pm, Peter Stephenson wrote:
} Subject: Re: Bug in alias expansion
} On Wed, 18 Nov 2015 07:52:46 -0800
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > On Nov 18,  2:13pm, Peter Stephenson wrote:
} > } Currently we expand both when parsing the entrails of the $(...)
} > } and executing it, but should possibly only do so in the latter case.
} > } I haven't look to see if this affects any tests.
} > 
} > Would not-expanding affect cmd_or_math() adversely?  Is that why we
} > expand and then backtrack?
} I can't offhand think of a case.  The crucial thing about cmd_or_math()
} is to get the parentheses right.

So it turns out that dquote_parse() has almost nothing to do with the
bug (though probably still a lot to do with whether the aliases ought
to expand at all); it's skipcomm() that causes the error.  This small
change fixes the problem seen in 37128:

diff --git a/Src/lex.c b/Src/lex.c
index 81904c1..0f260d0 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -2022,7 +2022,9 @@ skipcomm(void)
     int new_lexstop, new_lex_add_raw;
     int save_infor = infor;
     struct lexbufstate new_lexbuf;
+    int noalias = noaliases;
+    noaliases = 1;
     infor = 0;
@@ -2140,6 +2142,7 @@ skipcomm(void)
     infor = save_infor;
+    noaliases = noalias;
     return lexstop;

All "make check" tests still pass.  And now:

torch% alias -g foo='echo xyz)$(echo zyx'
torch% print $(foo)
zsh: parse error near `)'
zsh: parse error in command substitution

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