vbauerster / mpb

multi progress bar for Go cli applications
The Unlicense
2.29k stars 123 forks source link

if not a TTY, mpb still output control characters #119

Closed MichaelMure closed 1 year ago

MichaelMure commented 1 year ago

I may have done something slightly wrong or unexpected by using stdout for my progress bars instead of stderr, but I noticed that when redirecting the output to a file, mpb was not printing the progress bar itself, but still printed the control characters to manipulate the (non-existent) terminal. This resulted in those outputs in my file:

^[[2A^[[J

^[[2A^[[J

^[[2A^[[J

^[[2A^[[J

^[[2A^[[J

^[[2A^[[J

^[[2A^[[J

^[[2A^[[J

^[[2A^[[J

^[[2A^[[J

....

It's not a huge problem, but that still looks like a bug.

vbauerster commented 1 year ago

That has been fixed in v8.2.0. If output is not a TTY no any write will occur unless WithAutoRefresh option is set.

https://github.com/vbauerster/mpb/blob/3907ae91fd525b077c354b93d3b39ac1c75e533b/progress_test.go#L248

MichaelMure commented 1 year ago

Neat, thank you :-)