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)
Mar 8 2024, 6:32 PM
Unknown Object (File)
Jan 10 2024, 3:42 AM
Unknown Object (File)
Dec 11 2023, 6:34 AM
Unknown Object (File)
Nov 28 2023, 11:51 AM
Unknown Object (File)
Nov 21 2023, 3:43 AM
Unknown Object (File)
Nov 21 2023, 3:13 AM
Unknown Object (File)
Nov 13 2023, 4:01 PM
Unknown Object (File)
Nov 12 2023, 10:01 PM
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