1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-11-01 18:30:55 +01:00

42581(?): Fix ZLE inline history expansion.

Seen with magic-space.

If there's a parse error in command subtitution we need to complete
reading history to ensure the command line buffer is finished.
This commit is contained in:
Peter Stephenson 2018-04-04 18:33:00 +01:00
parent 1bd2ecc17d
commit 3517e4a9a5
4 changed files with 44 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2018-04-04 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 42581(?): Src/hist.c, Src/lex.c, Test/X03zlebindkey.ztst: history
expansion within ZLE needs history to be read to conclusion on
error.
2018-03-31 Oliver Kiddle <okiddle@yahoo.co.uk>
* 42572: Completion/Linux/Command/_ethtool,

View file

@ -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);
}
}
}
/*

View file

@ -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 */

View file

@ -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