Skip to contentSkip to conversation

shared/shell: Fix history display with no saved prompt

PATCH Applied Szymon Janc 1 participant 2 messages Feb 20, 2018 – Feb 21, 2018 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shared/shell: Fix history display with no saved prompt

Prompt needs to be restored always since default prompt is provided. This fix issues with history line being clobbered by offset of prompt length.

[bluetooth]# connect 9C:5C:F9:AB:C5:82 Attempting to connect to 9C:5C:F9:AB:C5:82 [bluetooth]# disconnect 9C:5C:F9:AB:C5:82 Attempting to disconnect from 9C:5C:F9:AB:C5:82 Failed to connect: org.bluez.Error.Failed Successful disconnected
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller 5C:E0:C5:34:AE:1C Discoverable: yes [bluetooth]# disconnect discoverable on

after pressing up-down
[bluetooth]# disconnect dis5C:F9:AB:C5:82

---
 src/shared/shell.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
src/shared/shell.c +4 -7
index 12330ff53..0ac492886 100644
@@ -378,11 +378,9 @@ void bt_shell_printf(const char *fmt, ...)
 	if (save_input) {
 		saved_point = rl_point;
 		saved_line = rl_copy_text(0, rl_end);
-		if (!data.saved_prompt) {
-			rl_save_prompt();
-			rl_replace_line("", 0);
-			rl_redisplay();
-		}
+		rl_save_prompt();
+		rl_replace_line("", 0);
+		rl_redisplay();
 	}
 
 	va_start(args, fmt);
@@ -390,8 +388,7 @@ void bt_shell_printf(const char *fmt, ...)
 	va_end(args);
 
 	if (save_input) {
-		if (!data.saved_prompt)
-			rl_restore_prompt();
+		rl_restore_prompt();
 		rl_replace_line(saved_line, 0);
 		rl_point = saved_point;
 		rl_forced_update_display();
Signature · 1 line
2.14.3
author Applied
#1 lore raw
Quoted 41 lines · On Tuesday, 20 February 2018 12:09:40 CET Szymon Janc wrote:

Prompt needs to be restored always since default prompt is provided. This fix issues with history line being clobbered by offset of prompt length.

[bluetooth]# connect 9C:5C:F9:AB:C5:82 Attempting to connect to 9C:5C:F9:AB:C5:82 [bluetooth]# disconnect 9C:5C:F9:AB:C5:82 Attempting to disconnect from 9C:5C:F9:AB:C5:82 Failed to connect: org.bluez.Error.Failed Successful disconnected
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller 5C:E0:C5:34:AE:1C Discoverable: yes [bluetooth]# disconnect discoverable on

after pressing up-down
[bluetooth]# disconnect dis5C:F9:AB:C5:82

---
 src/shared/shell.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
src/shared/shell.c +3 -5
index 12330ff53..0ac492886 100644
@@ -378,11 +378,9 @@ void bt_shell_printf(const char *fmt, ...)
 	if (save_input) {
 		saved_point = rl_point;
 		saved_line = rl_copy_text(0, rl_end);
-		if (!data.saved_prompt) {
-			rl_save_prompt();
-			rl_replace_line("", 0);
-			rl_redisplay();
-		}
+		rl_save_prompt();
+		rl_replace_line("", 0);
+		rl_redisplay();
 	}
 
 	va_start(args, fmt);

src/shared/shell.c void bt_shell_printf(const char *fmt, ...) · line 394

Quoted 9 lines
src/shared/shell.c +1 -2
@@ -390,8 +388,7 @@ void bt_shell_printf(const char *fmt, ...)
 	va_end(args);
 
 	if (save_input) {
-		if (!data.saved_prompt)
-			rl_restore_prompt();
+		rl_restore_prompt();
 		rl_replace_line(saved_line, 0);
 		rl_point = saved_point;
 		rl_forced_update_display();

Applied.

Signature · 2 lines
pozdrawiam
Szymon Janc