From 174b69afd6f2e2220620ffd572025ca2291cf533 Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Fri, 12 Jul 2024 08:30:29 -0500 Subject: [PATCH] cpukit/shell: Add window size retrieval control This adds an environment variable that can be used to enable or disable window size retrieval for the RTEMS shell. This will also disable window size retrieval upon failure while allowing the user to re-enable it. --- cpukit/libmisc/shell/shell.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c index 9c47a3f566..cb939dc1c5 100644 --- a/cpukit/libmisc/shell/shell.c +++ b/cpukit/libmisc/shell/shell.c @@ -936,6 +936,21 @@ static void rtems_shell_winsize( void ) int lines = 0; int cols = 0; int r; + const char *detect = getenv("TERM_SIZE_DETECT"); + + if (detect) { + /* Skip window size detection if set to False, false, or 0 */ + if (strcmp(detect, "false") == 0) { + return; + } + if (strcmp(detect, "False") == 0) { + return; + } + if (strcmp(detect, "0") == 0) { + return; + } + } + r = ioctl(fd, TIOCGWINSZ, &ws); if (r == 0) { ok = true; @@ -992,6 +1007,8 @@ static void rtems_shell_winsize( void ) setenv("LINES", buf, 1); snprintf(buf, sizeof(buf) - 1, "%d", cols); setenv("COLUMNS", buf, 1); + } else { + setenv("TERM_SIZE_DETECT", "0", 1); } }