Skip to content

Commit

Permalink
shared/shell: Add fixes for the init script scenario
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iulia-tanasescu authored and Vudentz committed Mar 8, 2024
1 parent 32e9d15 commit fcbea6f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/shared/shell.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fcbea6f

Please sign in to comment.