diff options
author | Iulia Tanasescu <iulia.tanasescu@nxp.com> | 2024-03-07 17:58:49 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2024-03-08 11:11:49 -0500 |
commit | fcbea6f3658d979622aad1a7f1311aaf0f7abd53 (patch) | |
tree | e3cd194341064c5d932c13062158a41fb0e31562 | |
parent | 32e9d15a60948ad1e912f6660e9dea6d8c5265d1 (diff) |
shared/shell: Add fixes for the init script scenario
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.
-rw-r--r-- | src/shared/shell.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/shared/shell.c b/src/shared/shell.c index 7bcfcff3ee..0e4cbb7b12 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) |