xbps-query(8): do not truncate output if stdout is not a tty.
This commit is contained in:
parent
2bead22e56
commit
bc97851fdb
4
NEWS
4
NEWS
@ -1,5 +1,9 @@
|
||||
xbps-0.45 (???):
|
||||
|
||||
* xbps-query(8): if piping or redirecting not a tty, don't enforce any columns limit.
|
||||
We do not want truncation in that case; this makes it possible to pipe the output
|
||||
to a pager without truncation.
|
||||
|
||||
* libfetch: added support for keep-alive connections even if the HTTP server returns
|
||||
304 (Not Modified). This is a noticable performance improvement for `xbps-install -S`.
|
||||
|
||||
|
@ -41,11 +41,17 @@ get_maxcols(void)
|
||||
{
|
||||
struct winsize ws;
|
||||
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0)
|
||||
return ws.ws_col ? ws.ws_col : 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
|
||||
print_package_line(const char *str, int maxcols, bool reset)
|
||||
|
@ -72,7 +72,7 @@ list_pkgs_in_dict(struct xbps_handle *xhp _unused,
|
||||
|
||||
tmp[i] = '\0';
|
||||
len = strlen(tmp) + strlen(short_desc) + 2;
|
||||
if (len > lpc->maxcols) {
|
||||
if (lpc->maxcols && len > lpc->maxcols) {
|
||||
out = malloc(lpc->maxcols+1);
|
||||
assert(out);
|
||||
snprintf(out, lpc->maxcols - 3,
|
||||
|
@ -80,7 +80,7 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
|
||||
inststr = "[-]";
|
||||
|
||||
len = strlen(inststr) + strlen(tmp) + strlen(desc) + 3;
|
||||
if ((int)len > sd->maxcols) {
|
||||
if (sd->maxcols && (int)len > sd->maxcols) {
|
||||
out = malloc(sd->maxcols+1);
|
||||
assert(out);
|
||||
snprintf(out, sd->maxcols-3, "%s %s %s",
|
||||
|
Loading…
Reference in New Issue
Block a user