Merge pull request #39 from spikeyspik/main

Fix: fallback to default terminal size on no tty
This commit is contained in:
Ryo Nakamura
2025-11-08 18:48:58 +09:00
committed by GitHub

View File

@@ -697,8 +697,13 @@ void print_progress_bar(double percent, char *suffix)
buf[0] = '\0';
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
return; /* XXX */
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0 || ws.ws_col == 0) {
// fallback to default
ws.ws_col = 80;
ws.ws_row = 24;
}
bar_width = min(sizeof(buf), ws.ws_col) - strlen(suffix) - 7;
memset(buf, 0, sizeof(buf));