From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: lexer issue
Date: Wed, 4 Apr 2018 18:10:12 +0100 [thread overview]
Message-ID: <20180404181012.6970637d@ntlworld.com> (raw)
In-Reply-To: <4294A9D0-3BF2-4EE5-8C7E-743DCFE2D2DD@ntlworld.com>
On Sat, 31 Mar 2018 18:17:21 +0100
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> When we do the recursive parse of the command subst we
> abort and flush the history on failure. But inside a string it
> doesn't bother finishing off the history line. That's important in
> this case because we're using that line directly as the string
> we get from the nested lex.
Here's the patch. Second test release will follow.
pws
diff --git a/Src/hist.c b/Src/hist.c
index b798be8..dbdc1e4 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -465,8 +465,26 @@ herrflush(void)
{
inpopalias();
- while (!lexstop && inbufct && !strin)
- hwaddc(ingetc());
+ if (lexstop)
+ return;
+ /*
+ * The lex_add_raw test is needed if we are parsing a command
+ * substitution when expanding history for ZLE: strin is set but we
+ * need to finish off the input because the string we are reading is
+ * going to be used directly in the line that goes to ZLE.
+ *
+ * Note that this is a side effect --- this is not the usual reason
+ * for testing lex_add_raw which is to add the text to a different
+ * buffer used when we are actually parsing the command substituion
+ * (nothing to do with ZLE). Sorry.
+ */
+ while (inbufct && (!strin || lex_add_raw)) {
+ int c = ingetc();
+ if (!lexstop) {
+ hwaddc(c);
+ addtoline(c);
+ }
+ }
}
/*
diff --git a/Src/lex.c b/Src/lex.c
index 2379804..44ad880 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -158,7 +158,7 @@ mod_export int nocomments;
/* add raw input characters while parsing command substitution */
/**/
-static int lex_add_raw;
+int lex_add_raw;
/* variables associated with the above */
diff --git a/Test/X03zlebindkey.ztst b/Test/X03zlebindkey.ztst
index 013d3df..298d7df 100644
--- a/Test/X03zlebindkey.ztst
+++ b/Test/X03zlebindkey.ztst
@@ -126,3 +126,20 @@
>CURSOR: 1
>BUFFER: ホ
>CURSOR: 1
+
+ zpty_run 'bindkey " " magic-space'
+ setopt interactivecomments
+ zletest 'echo $(( x ) x ) y'
+ zletest 'echo $(( ##x ) ##x ) y'
+ unsetopt interactivecomments
+ zletest 'echo $(( x ) x ) y'
+ zletest 'echo $(( ##x ) ##x ) y'
+0:history expansion of failed command substitution using magic-space binding
+>BUFFER: echo $(( x ) x ) y
+>CURSOR: 18
+>BUFFER: echo $(( ##x ) ##x ) y
+>CURSOR: 22
+>BUFFER: echo $(( x ) x ) y
+>CURSOR: 18
+>BUFFER: echo $(( ##x ) ##x ) y
+>CURSOR: 22
prev parent reply other threads:[~2018-04-05 0:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180327111617epcas3p264cdae264e676ace2503d20bd919ea5e@epcas3p2.samsung.com>
2018-03-27 11:05 ` Oliver Kiddle
2018-03-27 11:56 ` Peter Stephenson
2018-03-28 9:57 ` Oliver Kiddle
2018-03-31 17:17 ` Peter Stephenson
2018-04-04 17:10 ` Peter Stephenson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180404181012.6970637d@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).