Page MenuHomeFreeBSD

w: don't truncate argument list if --libxo was specified
AbandonedPublic

Authored by yuripv on May 26 2020, 8:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 7, 3:48 PM
Unknown Object (File)
Sat, Nov 30, 11:26 PM
Unknown Object (File)
Sun, Nov 17, 8:51 PM
Unknown Object (File)
Oct 31 2024, 2:43 PM
Unknown Object (File)
Oct 25 2024, 1:55 PM
Unknown Object (File)
Sep 30 2024, 7:28 PM
Unknown Object (File)
Sep 30 2024, 8:14 AM
Unknown Object (File)
Sep 29 2024, 9:12 AM
Subscribers

Details

Summary

Don't limit the 'what' field if --libxo was specified.

Provide xo_libxo_set() function to let consumers know if initial flags were specified using --libxo and use it to decide if output should be truncated to fit in terminal width, or use ARG_MAX for 'what' field length instead.

If this looks reasonable, I'll submit a PR for libxo on github. And if there's some simple obvious way to get the same information that I missed, please let me know!

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

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)"?

Thanks,
Phil

In D25013#550908, @phil wrote:

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)"?

Thanks,
Phil

This is the easiest way to provide an option for w to not truncate argument list (see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246514) as basing decision on whether the output is to terminal or not is likely to break POLA, and if you specify --libxo, you know what you are asking for, even if it's text or HTML. If you disagree, could you please a comment to the PR?

Apologies, I missed your reply to my question, but it's still something I'm not following:

Is it sufficient to know if the output is text format, using "if (xo_get_style(NULL) == XO_STYLE_TEXT)"?

One issue is that the output of "w" and "w --libxo text" should be identical. The presence of "--libxo" shouldn't matter, just the selected output format.

Thanks,
Phil

Correction: for your patch the test would be opposite:

if (xo_get_style(NULL) != XO_STYLE_TEXT) {
    argwidth = ARG_MAX;
} else {
    ...

Thanks,
Phil