fix(unix): fetch COLUMNS when we don't have a terminal width

This commit is contained in:
Jan De Dobbeleer 2024-02-07 08:11:26 +01:00 committed by Jan De Dobbeleer
parent bb5e1b1a2e
commit 93d0cac0db

View file

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