Fix nested commands in interactive mode triggering prompt2 (issue #19)

Save and restore cmd_mode across interpolation parsing so that
luaX_readcommandcont resumes in the correct mode after a nested
backtick command inside ${...}.
This commit is contained in:
Cormac Shannon
2026-03-05 00:13:34 +00:00
parent b3aa1d9c63
commit c96fae90c0
4 changed files with 12 additions and 1 deletions

2
llex.c
View File

@@ -512,6 +512,7 @@ static int read_command_body (LexState *ls, SemInfo *seminfo) {
/* store fragment so far */
seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
luaZ_bufflen(ls->buff));
ls->saved_cmd_mode = ls->cmd_mode; /* save for readcommandcont */
return interactive ? TK_INTERACTIVE_INTERP : TK_COMMAND_INTERP;
}
else {
@@ -571,6 +572,7 @@ static int read_command (LexState *ls, SemInfo *seminfo) {
** consumed the '}' that closes an interpolated ${expr}.
*/
int luaX_readcommandcont (LexState *ls) {
ls->cmd_mode = ls->saved_cmd_mode; /* restore mode from before interpolation */
int tk = read_command_body(ls, &ls->t.seminfo);
ls->t.token = tk;
return tk;