cli: Avoid sending ANSI characters to a non-terminal

Detect if there is no terminal present (this only works on sandbox) and
skip sending ANSI characters when the CLI starts up. This avoids having
them in logs, for example.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-08-22 07:38:09 -06:00
parent ae8fb2dbf1
commit 8aa1e7c81e

View File

@@ -20,6 +20,7 @@
#include <fdtdec.h>
#include <hang.h>
#include <malloc.h>
#include <serial.h>
#include <asm/global_data.h>
#include <dm/ofnode.h>
#include <linux/errno.h>
@@ -337,6 +338,6 @@ void cli_init(void)
hush_init_var();
#endif
if (CONFIG_IS_ENABLED(VIDEO_ANSI))
if (CONFIG_IS_ENABLED(VIDEO_ANSI) && serial_is_tty())
printf(ANSI_CURSOR_SHOW "\n");
}