From 61a5c826c8472a8d9058ebb93e5fbbc5796cd46d Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 23 Jan 2007 16:07:46 +0000 Subject: 23126, modified: bug in zle history inside $( and $(( --- ChangeLog | 7 +++++++ Src/lex.c | 25 ++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1e7aa713..fc9ceeddf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-01-23 Peter Stephenson + + * 23126, modified: Src/lex.c: errors when deciding between + $(( and $( were not handled properly and in particular caused + problems in history expansion in zle. The code is a little + obscure; added a comment about this. + 2007-01-22 Peter Stephenson * 23122: Src/sort.c: bug with some strings with embedded nulls and diff --git a/Src/lex.c b/Src/lex.c index 095d58150..7748bedad 100644 --- a/Src/lex.c +++ b/Src/lex.c @@ -542,14 +542,14 @@ cmd_or_math(int cs_type) c = dquote_parse(')', 0); cmdpop(); *bptr = '\0'; - if (!c) { - c = hgetc(); - if (c == ')') - return 1; - hungetc(c); - lexstop = 0; - c = ')'; - } + if (c) + return 1; + c = hgetc(); + if (c == ')') + return 1; + hungetc(c); + lexstop = 0; + c = ')'; hungetc(c); lexstop = 0; while (len > oldlen) { @@ -1436,8 +1436,15 @@ dquote_parse(char endchar, int sub) cmdpop(); if (lexstop) err = intick || endchar || err; - else if (err == 1) + else if (err == 1) { + /* + * TODO: as far as I can see, this hack is used in gettokstr() + * to hungetc() a character on an error. However, I don't + * understand what that actually gets us, and we can't guarantee + * it's a character anyway, because of the previous test. + */ err = c; + } if (zlemath && zlemetacs <= zlemetall + 1 - inbufct) inwhat = IN_MATH; return err; -- cgit 1.4.1