Skip to content

Commit 11a4ba6

Browse files
author
Chris Pine
authored
fix for crash when progress bars had a length of zero (#289)
Co-authored-by: Chris Pine <[email protected]>
1 parent 3664d28 commit 11a4ba6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/output/progress_tty.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ func (p *progressTTY) writeLine(bar *ProgressBar) {
208208

209209
// Unicode box drawing gives us eight possible bar widths, so we need to
210210
// calculate both the bar width and then the final character, if any.
211-
segments := int(math.Round((float64(8*barWidth) * value) / bar.Max))
211+
var segments int
212+
if bar.Max > 0 {
213+
segments = int(math.Round((float64(8*barWidth) * value) / bar.Max))
214+
}
215+
212216
fillWidth := segments / 8
213217
remainder := segments % 8
214218
if remainder == 0 {

0 commit comments

Comments
 (0)