From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3379 invoked by alias); 5 Apr 2018 00:01:36 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42581 Received: (qmail 2511 invoked by uid 1010); 4 Apr 2018 17:20:50 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-7.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.71):SA:0(-1.9/5.0):. Processed in 15.195424 secs); 04 Apr 2018 17:20:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Originating-IP: [86.21.219.59] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=Tei4SyYh c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=IkcTkHD0fZMA:10 a=x7bEGLp0ZPQA:10 a=NLZqzBF-AAAA:8 a=aFNtbzcQ-fummtKiC6EA:9 a=QEXdDO2ut3YA:10 a=wW_WBVUImv98JQXhvVPZ:22 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== Date: Wed, 4 Apr 2018 18:10:12 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: lexer issue Message-ID: <20180404181012.6970637d@ntlworld.com> In-Reply-To: <4294A9D0-3BF2-4EE5-8C7E-743DCFE2D2DD@ntlworld.com> References: <5777.1522148738@thecus> <20180327125641.3df8e5a1@camnpupstephen.cam.scsc.local> <9531.1522231067@thecus> <4294A9D0-3BF2-4EE5-8C7E-743DCFE2D2DD@ntlworld.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-CMAE-Envelope: MS4wfKWUicbClJpp6O9vnYD7HZJOa7s0aWmkJpNAZjlfuVuOW4WV8+Xb1Zn/A9GDsOkuEG6bSPfe+PfUTYKET8Tx6Ed4iXQa01cSve0Z/AgMBkg6rybUOJis 7/Dl6X+xBQrU2eW8XckGhuGv0G9jmkf2kBUP3XzYgpSBvIhPHjJHLgDQbf8W+chtwA5lwaxPVjryJg== On Sat, 31 Mar 2018 18:17:21 +0100 Peter Stephenson 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(); =20 - 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 =3D ingetc(); + if (!lexstop) { + hwaddc(c); + addtoline(c); + } + } } =20 /* 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 */ =20 /**/ -static int lex_add_raw; +int lex_add_raw; =20 /* variables associated with the above */ =20 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: =E3=83=9B >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 bindi= ng +>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