w: don't truncate if we're writing libxo json/xml

If we're writing structured output (i.e. json or xml) we shouldn't worry
about terminal width, and instead always output full width information.

This means that, for example, if we're called from crontab with 'w
--libxo json' we'll provide full the command field rather than
pointlessly truncating it.

Suggested by:	Phil Shafer
Event:		Aberdeen Hackathon 2022
Differential Revision:	https://reviews.freebsd.org/D25013
This commit is contained in:
Kristof Provost 2022-10-07 18:14:02 +02:00
parent 947fcb84b7
commit 307625842b

View file

@ -390,6 +390,9 @@ main(int argc, char *argv[])
argwidth = ttywidth - WUSED;
if (argwidth < 4)
argwidth = 8;
/* Don't truncate if we're outputting json or XML. */
if (xo_get_style(NULL) != XO_STYLE_TEXT)
argwidth = ARG_MAX;
for (ep = ehead; ep != NULL; ep = ep->next) {
if (ep->kp == NULL) {
ep->args = strdup("-");