ps output line length (was: svn commit: r314685 - head/bin/ps)

Garance A Drosehn drosih at rpi.edu
Mon Jan 29 22:36:02 UTC 2018


On 28 Jan 2018, at 11:22, Mike Karels wrote:

> The rationale for the original code was that, for interactive uses, the
> output line length should be the same for "ps ...", "ps ...|more", and
> "ps ... |grep".  The -w option exists to make the line longer; there is
> no option to use the terminal size even if the output is redirected.
> Hence, the tests for stderr or stdin being a tty.  This behavior has
> been in place since 1990, as noted, and no substantial rationale has
> been given for changing it other than "it doesn't matter if you use
> less with side-to-side scrolling."  fwiw, I'm sure I discussed that
> code with Marc at the time.
>
> As was stated, scripts that want to use the full line should use -ww.
> Interactive users have long been used to using -w when they need longer
> output lines, e.g. to match patterns that don't occur within a screen's
> width.
>
> I propose reverting this change.

I do have several scripts which work on the output of 'ps', and none
of my scripts would have noticed this change because they include -ww
and they also set 'local COLUMNS=180' and export the value of COLUMNS.

It also looks like the change from March 2017 is only in -current,
and has not been MFC-ed into 11.x-stable.

So reverting the change seems reasonable to me.

I will note that the behavior of 'ps' on linux seems to match what the
change does.  If you 'ps axu' the output is the width of your terminal,
and if you 'ps axu | grep something' then the output width seems to be
infinity (or at least it's somewhere over 2500 characters).

I have not checked how 'ps' acts on the other BSD's.

-- 
Garance Alistair Drosehn                =     drosih at rpi.edu
Senior Systems Programmer               or   gad at FreeBSD.org
Rensselaer Polytechnic Institute;             Troy, NY;  USA


More information about the svn-src-all mailing list