On Mon, 6 Mar 2017, Bryan Drewery wrote:
On 3/6/17 8:11 PM, Bryan Drewery wrote:
On 3/4/17 2:38 PM, Conrad Meyer wrote:
Author: cem
Date: Sat Mar 4 22:38:10 2017
New Revision: 314685
URL: https://svnweb.freebsd.org/changeset/base/314685
Log:
ps(1): Only detect terminal width if stdout is a tty
If stdout isn't a tty, use unlimited width output rather than truncating to
79 characters. This is helpful for shell scripts or e.g., 'ps | grep foo'.
This change actually makes things worse for me for 'ps uaxwd|less'
No surprise.
Before:
nobody 83979 0.0 0.0 9016 1364 3 I+J 20:03 0:00.06 | |
`-- /usr/bin/make -C /usr/ports/lang/perl5.24 build
After:
nobody 89743 0.0 0.0 9016 1368 3 S+J 20:07 0:00.05 | |
`-- /usr/bin/make -C /usr/ports/lang/perl5.24
I now have to specify -ww to not cut things off, but that's far more
than I want to see.
The problem is that -w is parsed *after* termwidth = UNLIMITED is set
(which is 0). This patch fixes it, but I haven't tested it extensively:
Index: ps.c
===================================================================
--- ps.c (revision 314708)
+++ ps.c (working copy)
@@ -401,7 +401,7 @@ main(int argc, char *argv[])
case 'w':
if (wflag)
termwidth = UNLIMITED;
- else if (termwidth < 131)
+ else if (termwidth < 131 && termwidth != UNLIMITED)
termwidth = 131;
I pointed out many nearby bugs, but missed this one. 0 is a fail-unsafe
value for UNLIMITED. 0 for the default width of 79 unless modified by
-w and INT_MAX for UNLIMITED would be less magic.
ps now has complications using xo. It now uses the POSIX mistake
_POSIX2_LINE_MAX for at least xo output, so UNLIMITED no longer means
unlimited. _POSIX2_LINE_MAX is only 2048. Probably good enough for
ps. So UNLIMITED should be unobfuscated by spelling it
(_POSIX2_LINE_MAX - 1). The user's COLUMNS is not honored when it is
larger than this, and the user can do foot shooting by setting COLUMNS
to the current internal magic value for UNLIMIT or exercise sign extension
and overflow bugs by setting it to negative. 'COLUMNS=-1 ps' actually
gives normal output except for messing up the COMAMND column (e.g.,
"-bash (bash)" becomes "[bash]". I forget what the brackets mean, and
this is not documented in ps.1.
wflag++;
break;
-1 for the original commit. If I wanted -ww I would specify it. The
original commit causes some text to wrap on my terminal even with some
extending right.
Bruce
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"