[Concept,v2,09/16] cli: Avoid sending ANSI characters to a non-terminal

Message ID 20250825162727.3185381-10-sjg@u-boot.org
State New
Headers
Series console: Refactor in preparation for the pager |

Commit Message

Simon Glass Aug. 25, 2025, 4:27 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

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>
---

(no changes since v1)

 common/cli.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/common/cli.c b/common/cli.c
index 4694a35cd0e..23988330dd8 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -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");
 }