Skip to content

Commit

Permalink
Merge pull request #91 from rafaelmartins/stderr-width
Browse files Browse the repository at this point in the history
try to get stderr width if stdout is not a terminal
  • Loading branch information
schollz authored Nov 23, 2020
2 parents 7580942 + 31fc10c commit b97839d
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 b97839d

Please sign in to comment.