Diff between 868d8fc5dcf60ada2e509b6d13a3f86b57181080 and e6d849f38be30d4a27262c0a8b6c651aac0d79c9

Changed Files

File Additions Deletions Status
src/shared/shell.c +9 -10 modified

Full Patch

diff --git a/src/shared/shell.c b/src/shared/shell.c
index d68d679..f3f7bab 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -863,8 +863,6 @@ int bt_shell_release_prompt(const char *input)
 
 static void rl_handler(char *input)
 {
-	HIST_ENTRY *last;
-
 	if (!input) {
 		rl_insert_text("quit");
 		rl_redisplay();
@@ -879,14 +877,6 @@ static void rl_handler(char *input)
 	if (!bt_shell_release_prompt(input))
 		goto done;
 
-	last = history_get(history_length + history_base - 1);
-	/* append only if input is different from previous command */
-	if (!last || strcmp(input, last->line))
-		add_history(input);
-
-	if (data.monitor)
-		bt_log_printf(0xffff, data.name, LOG_INFO, "%s", input);
-
 	bt_shell_exec(input);
 
 done:
@@ -1404,12 +1394,21 @@ int bt_shell_run(void)
 
 int bt_shell_exec(const char *input)
 {
+	HIST_ENTRY *last;
 	wordexp_t w;
 	int err;
 
 	if (!input)
 		return 0;
 
+	last = history_get(history_length + history_base - 1);
+	/* append only if input is different from previous command */
+	if (!last || strcmp(input, last->line))
+		add_history(input);
+
+	if (data.monitor)
+		bt_log_printf(0xffff, data.name, LOG_INFO, "%s", input);
+
 	err = wordexp(input, &w, WRDE_NOCMD);
 	switch (err) {
 	case WRDE_BADCHAR: