From 31fc10c09a1cc38b5784779d2a3d67b4ef4aa95c Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sat, 21 Nov 2020 16:56:33 +0100 Subject: [PATCH] try to get stderr width if stdout is not a terminal --- progressbar.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/progressbar.go b/progressbar.go index 1c2a2eb..f6cacab 100644 --- a/progressbar.go +++ b/progressbar.go @@ -655,7 +655,10 @@ func renderProgressBar(c config, s state) (int, error) { if c.fullWidth && !c.ignoreLength { width, _, err := terminal.GetSize(int(os.Stdout.Fd())) if err != nil { - width = 80 + width, _, err = terminal.GetSize(int(os.Stderr.Fd())) + if err != nil { + width = 80 + } } c.width = width - len(c.description) - 14 - len(bytesString) - len(leftBrac) - len(rightBrac)