mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Fix terminal width calculating causing error on some systems
This commit is contained in:
parent
449cc37896
commit
23bb9fdbd6
1 changed files with 7 additions and 1 deletions
|
|
@ -164,7 +164,13 @@ func terminalWidth() int {
|
|||
if err != nil {
|
||||
return 60
|
||||
}
|
||||
width, err := strconv.Atoi(strings.Split(strings.ReplaceAll(string(res), "\n", ""), " ")[1])
|
||||
// on alpine linux the command `stty size` does not respond the terminal size
|
||||
// but something like "stty: standard input". this may also apply to other systems
|
||||
splitOutput := strings.SplitN(strings.ReplaceAll(string(res), "\n", ""), " ", 2)
|
||||
if len(splitOutput) == 1 {
|
||||
return 60
|
||||
}
|
||||
width, err := strconv.Atoi(splitOutput[1])
|
||||
if err != nil {
|
||||
return 60
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue