Page MenuHomeFreeBSD

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

Authored by yuripv on May 26 2020, 8:34 AM.

Details

Reviewers
kevans
phil
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
Lint
Lint Skipped
Unit
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?