From 93d0cac0dbcfcd1264bc852c5e919b159a4dcfcc Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Wed, 7 Feb 2024 08:11:26 +0100 Subject: [PATCH] fix(unix): fetch COLUMNS when we don't have a terminal width --- src/platform/shell_unix.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/platform/shell_unix.go b/src/platform/shell_unix.go index caca352a..156f1453 100644 --- a/src/platform/shell_unix.go +++ b/src/platform/shell_unix.go @@ -66,6 +66,16 @@ func (env *Shell) TerminalWidth() (int, error) { env.Error(err) } + // fetch width from the environment variable + // in case the terminal width is not available + if width == 0 { + i, err := strconv.Atoi(env.Getenv("COLUMNS")) + if err != nil { + env.Error(err) + } + width = uint(i) + } + env.CmdFlags.TerminalWidth = int(width) env.DebugF("terminal width: %d", env.CmdFlags.TerminalWidth) return env.CmdFlags.TerminalWidth, err