[PATCH BlueZ 3/4] shared/shell: Add fixes for the init script scenario

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds some fixes to the scenario when the shell is run with
the -i/--init-script command line option.

In bt_shell_dequeue_exec, if a prompt was released with the current
line, all other prompts, if any left, should also try to be released.
If no other prompts are available, the next line should be executed
on bt_shell_noninteractive_quit.

In bt_shell_prompt_input, if data is already available in data.queue,
execution should continue and the prompt should be released with the
input.
---
 src/shared/shell.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index 7bcfcff3e..0e4cbb7b1 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -638,7 +638,15 @@ static void bt_shell_dequeue_exec(void)
 	bt_shell_printf("%s\n", data.line);
 
 	if (!bt_shell_release_prompt(data.line)) {
-		bt_shell_dequeue_exec();
+		/* If a prompt was released with this line,
+		 * try to release all the other prompts,
+		 * if any are left. Otherwise, the next
+		 * line will be executed on
+		 * bt_shell_noninteractive_quit.
+		 */
+		if (data.saved_prompt)
+			bt_shell_dequeue_exec();
+
 		return;
 	}
 
@@ -693,6 +701,13 @@ void bt_shell_prompt_input(const char *label, const char *msg,
 	prompt_input(str, func, user_data);
 
 	free(str);
+
+	if (data.line && !queue_isempty(data.queue))
+		/* If a prompt was set to receive input and
+		 * data is already available, try to execute
+		 * the line and release the prompt.
+		 */
+		bt_shell_dequeue_exec();
 }
 
 static void prompt_free(void *data)
-- 
2.39.2





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux