Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: lexer issue
- X-seq: zsh-workers 42581
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: lexer issue
- Date: Wed, 4 Apr 2018 18:10:12 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1522861815; bh=7+UQS8ox0GCrx7dNpGpYvu1uAicK+I0UCCTW2PUt704=; h=Date:From:To:Subject:In-Reply-To:References; b=YoiSbrvF6AxLm+H911Stak3GkR8pj00LOw/TpBe9KeucJcNEmgcxyYD8NHy1+1KG+ 5ZGXMrp8tsJoexdFh0NXLSsCLh1uYv5zIhmp6N+hYlm6tiL8YGypblJzyMI6HRqs3e pBHzG8cAOCuNiAAXL+I3owz7/4+HZTNn2cGXYQ25dP4xOI4LlI4ziSNyY3inGe/NCH dONfPLPXcRjym3AcRNwKQIHS1kZRdFp75LF7F/V3kmm9xTzKqYgms42coj/UqzYRwn YT3gKm1OwYZK+S5SGtLRy4Cyd0uSU5VMbf7VQuzQUxgHe3SvSW5Po0E0O4NfrIejf1 cbpg9a6VcD0og==
- In-reply-to: <4294A9D0-3BF2-4EE5-8C7E-743DCFE2D2DD@ntlworld.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20180327111617epcas3p264cdae264e676ace2503d20bd919ea5e@epcas3p2.samsung.com> <5777.1522148738@thecus> <20180327125641.3df8e5a1@camnpupstephen.cam.scsc.local> <9531.1522231067@thecus> <4294A9D0-3BF2-4EE5-8C7E-743DCFE2D2DD@ntlworld.com>
On Sat, 31 Mar 2018 18:17:21 +0100
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author