When calling w(1) as
or any other output format, values - particularly the WHAT column - gets truncated by the terminal size at the time of invocation. This is particularly troublesome when called in a non-terminal session e.g. from cron(8), as it will then default to 79 characters.
It could be argued that unless the output is a terminal, it should not make any assumptions about or adaptations to terminal size at all. For example, w|head should not truncate. However, changing this behaviour might be a violation of the POLA.
Truncating output prior to passing to libxo shoul, however, probably be considered a bug.
> For example, w|head should not truncate.
Good luck. :-) I've never been able to convince anyone of that.
If nobody is working (or plans to work) on this, I'll ask one of our people to have a crack at it. I guess it won't make it to 11.4 anyway..
(In reply to Eirik Oeverby from comment #2)
The code change here is easy and obvious, getting it integrated however isn't, as Conrad mentioned.
(In reply to Yuri Pankov from comment #3)
Even if _only_ the --libxo case is fixed?
(In reply to Eirik Oeverby from comment #4)
I'd be willing to take any heat for committing a patch to fix just the --libxo case.
I think it's quite feasible to get the libxo case fixed for 11.4.
Created attachment 214657 [details]
don't truncate argument list if --libxo was specified
(I'm on very limited internet connection at the moment so attaching the patch I came up with here.)
Proposed patch adding a xo_libxo_set() to libxo to let consumers know if --libxo was specified in the command line arguments passed to xo_parse_args(), and use it in w to decide if we should truncate the argument list.
Just knowing that the "--libxo" was used is not sufficient, since there are options that should not affect output (e.g. color, no-humanize, warn).
Can you describe more exactly when you want to avoid truncation? I'm guessing you want this for the "encoding" output styles (XML, JSON) and not text, but do you want to truncate HTML output?
Maybe the test you are needing is just "if (xo_get_style(NULL) == XO_STYLE_TEXT)"?