shell: suppress newlines on boot when promt is an empty string

If the user sets the default_prompt to an empty string no newlines will
be printed during boot.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
This commit is contained in:
Gerhard Jörges 2022-05-18 14:57:30 +02:00 committed by Carles Cufí
commit d99827f0a5
2 changed files with 11 additions and 5 deletions

View file

@ -37,7 +37,8 @@ config SHELL_PROMPT_UART
string "Displayed prompt name"
default "uart:~$ "
help
Displayed prompt name for UART backend.
Displayed prompt name for UART backend. If prompt is set, the shell will
send two newlines during initialization.
# Internal config to enable UART interrupts if supported.
config SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN
@ -133,7 +134,8 @@ config SHELL_PROMPT_RTT
string "Displayed prompt name"
default "rtt:~$ "
help
Displayed prompt name for RTT backend.
Displayed prompt name for RTT backend. If prompt is set, the shell will
send two newlines during initialization.
config SHELL_RTT_RX_POLL_PERIOD
int "RX polling period (in milliseconds)"
@ -296,7 +298,8 @@ config SHELL_PROMPT_TELNET
string "Displayed prompt name"
default "~$ "
help
Displayed prompt name for TELNET backend.
Displayed prompt name for TELNET backend. If prompt is set, the shell will
send two newlines during initialization.
config SHELL_TELNET_PORT
int "Telnet port number"
@ -390,7 +393,8 @@ config SHELL_PROMPT_DUMMY
string "Displayed prompt name"
default "~$ "
help
Displayed prompt name for DUMMY backend.
Displayed prompt name for DUMMY backend. If prompt is set, the shell will
send two newlines during initialization.
config SHELL_BACKEND_DUMMY_BUF_SIZE
int "Size of dummy buffer size"

View file

@ -1413,7 +1413,9 @@ int shell_start(const struct shell *shell)
z_shell_vt100_color_set(shell, SHELL_NORMAL);
}
z_shell_raw_fprintf(shell->fprintf_ctx, "\n\n");
if (z_shell_strlen(shell->default_prompt) > 0) {
z_shell_raw_fprintf(shell->fprintf_ctx, "\n\n");
}
state_set(shell, SHELL_STATE_ACTIVE);
k_mutex_unlock(&shell->ctx->wr_mtx);