From owner-svn-src-head@freebsd.org Tue Mar 7 05:53:52 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31A6BD01CE9; Tue, 7 Mar 2017 05:53:52 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id ECDE4180E; Tue, 7 Mar 2017 05:53:51 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-153-191.carlnfd1.nsw.optusnet.com.au [122.106.153.191]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 9241C1047D0E; Tue, 7 Mar 2017 16:53:47 +1100 (AEDT) Date: Tue, 7 Mar 2017 16:53:46 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bryan Drewery cc: Conrad Meyer , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r314685 - head/bin/ps In-Reply-To: <52877752-ab4b-45ea-05f4-ef050e1a2983@FreeBSD.org> Message-ID: <20170307161527.X10112@besplex.bde.org> References: <201703042238.v24McAD8008837@repo.freebsd.org> <01dddec8-89c0-e18a-a481-e802643f9e0e@FreeBSD.org> <52877752-ab4b-45ea-05f4-ef050e1a2983@FreeBSD.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=VbSHBBh9 c=1 sm=1 tr=0 a=Tj3pCpwHnMupdyZSltBt7Q==:117 a=Tj3pCpwHnMupdyZSltBt7Q==:17 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=0ilfchANsudAHDDNryAA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Mar 2017 05:53:52 -0000 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