xbps-query(8): do not truncate output if stdout is not a tty.

This commit is contained in:
Juan RP
2015-04-15 18:40:34 +02:00
parent 2bead22e56
commit bc97851fdb
4 changed files with 16 additions and 6 deletions

View File

@@ -41,10 +41,16 @@ get_maxcols(void)
{
struct winsize ws;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0)
return ws.ws_col ? ws.ws_col : 80;
return 80;
if (!isatty(STDOUT_FILENO) && errno == ENOTTY) {
/* not a TTY, don't use any limit */
return 0;
}
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1) {
/* 80x24 terminal */
return 80;
}
/* TTY columns */
return ws.ws_col;
}
void