Skip to content

Commit

Permalink
try to get stderr width if stdout is not a terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmartins committed Nov 21, 2020
1 parent 7580942 commit 31fc10c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 31fc10c

Please sign in to comment.