From 9a135e0826626f16def8dd1e8fa9274db1f11b99 Mon Sep 17 00:00:00 2001 From: Jacob Lin Date: Thu, 7 Mar 2024 01:19:01 +0800 Subject: [PATCH 1/2] Remove unused variable `prompt_flag` in `console.c` is specified as static and the only usage is the if statement at line 583 and the only assignment to it is at line 588 which assigns 1 to `prompt_flag`. Since no other code can modify this variable, it can be removed. --- console.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/console.c b/console.c index 3745c9666..dda251fd5 100644 --- a/console.c +++ b/console.c @@ -21,7 +21,6 @@ int show_entropy = 0; static cmd_element_t *cmd_list = NULL; static param_element_t *param_list = NULL; static bool block_flag = false; -static bool prompt_flag = true; /* Am I timing a command that has the console blocked? */ static bool block_timing = false; @@ -581,13 +580,12 @@ static int cmd_select(int nfds, if (web_fd != -1) FD_SET(web_fd, readfds); - if (infd == STDIN_FILENO && prompt_flag) { + if (infd == STDIN_FILENO) { char *cmdline = linenoise(prompt); if (cmdline) interpret_cmd(cmdline); fflush(stdout); - prompt_flag = true; - } else if (infd != STDIN_FILENO) { + } else { char *cmdline = readline(); if (cmdline) interpret_cmd(cmdline); From adecb4f73edff447ae84ac9dd11cf241bbb9fdd4 Mon Sep 17 00:00:00 2001 From: Jacob Lin Date: Thu, 7 Mar 2024 01:27:18 +0800 Subject: [PATCH 2/2] Fix command prompt showing when using file input Commit dd6a761 removes `set_echo(0)` when `infd` is not the standard input, which will show command prompt while executing command from input files. Adding it back fixes the issue. --- console.c | 1 + 1 file changed, 1 insertion(+) diff --git a/console.c b/console.c index dda251fd5..9c3dfbae0 100644 --- a/console.c +++ b/console.c @@ -586,6 +586,7 @@ static int cmd_select(int nfds, interpret_cmd(cmdline); fflush(stdout); } else { + set_echo(0); char *cmdline = readline(); if (cmdline) interpret_cmd(cmdline);