From owner-svn-src-head@freebsd.org Tue Mar 7 04:26:42 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 9A8D8D019FD; Tue, 7 Mar 2017 04:26:42 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6D0C01942; Tue, 7 Mar 2017 04:26:42 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by freefall.freebsd.org (Postfix) with ESMTPS id 8D1F562C; Tue, 7 Mar 2017 04:26:41 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [172.31.3.2]) by mail.xzibition.com (Postfix) with ESMTP id 890E8354A0; Tue, 7 Mar 2017 04:26:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at mail.xzibition.com Received: from mail.xzibition.com ([172.31.3.2]) by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new, port 10026) with LMTP id O1V8Dihuw2yo; Tue, 7 Mar 2017 04:26:21 +0000 (UTC) Subject: Re: svn commit: r314685 - head/bin/ps DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com 8E5E83549B To: Conrad Meyer , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201703042238.v24McAD8008837@repo.freebsd.org> <01dddec8-89c0-e18a-a481-e802643f9e0e@FreeBSD.org> From: Bryan Drewery Organization: FreeBSD Message-ID: <52877752-ab4b-45ea-05f4-ef050e1a2983@FreeBSD.org> Date: Mon, 6 Mar 2017 20:26:14 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <01dddec8-89c0-e18a-a481-e802643f9e0e@FreeBSD.org> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gTltGfjTpF8TIjHLg0sX0GM4Qr512rC7f" 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 04:26:42 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --gTltGfjTpF8TIjHLg0sX0GM4Qr512rC7f Content-Type: multipart/mixed; boundary="iCNvVh0AeaLkKqtwAFqavhhXGPHmuODwi"; protected-headers="v1" From: Bryan Drewery To: Conrad Meyer , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <52877752-ab4b-45ea-05f4-ef050e1a2983@FreeBSD.org> Subject: Re: svn commit: r314685 - head/bin/ps References: <201703042238.v24McAD8008837@repo.freebsd.org> <01dddec8-89c0-e18a-a481-e802643f9e0e@FreeBSD.org> In-Reply-To: <01dddec8-89c0-e18a-a481-e802643f9e0e@FreeBSD.org> --iCNvVh0AeaLkKqtwAFqavhhXGPHmuODwi Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 >> =20 >> If stdout isn't a tty, use unlimited width output rather than trunca= ting to >> 79 characters. This is helpful for shell scripts or e.g., 'ps | gre= p foo'. >=20 > This change actually makes things worse for me for 'ps uaxwd|less' >=20 > Before: >> nobody 83979 0.0 0.0 9016 1364 3 I+J 20:03 0:00= =2E06 | | `-- /usr/bin/make -C /usr/ports/lang/perl5.24 build >=20 > After: >> nobody 89743 0.0 0.0 9016 1368 3 S+J 20:07 0:00= =2E05 | | `-- /usr/bin/make -C /usr/ports/lang/perl5.24 >=20 >=20 > I now have to specify -ww to not cut things off, but that's far more > than I want to see. >=20 The problem is that -w is parsed *after* termwidth =3D UNLIMITED is set (which is 0). This patch fixes it, but I haven't tested it extensively: > Index: ps.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- ps.c (revision 314708) > +++ ps.c (working copy) > @@ -401,7 +401,7 @@ main(int argc, char *argv[]) > case 'w': > if (wflag) > termwidth =3D UNLIMITED; > - else if (termwidth < 131) > + else if (termwidth < 131 && termwidth !=3D UNLI= MITED) > termwidth =3D 131; > 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. >=20 >> =20 >> This hardcoded width has some history: In The Beginning of History[0= ], the >> width of ps was hardcoded as 80 bytes. In 1985, Bloom@ added detect= ion >> using TIOCGWINSZ on stdin.[1] In 1986, Kirk merged a change to chec= k >> stdout's window size instead. In 1990, the fallback checks to stder= r and >> stdin's TIOCGWINSZ were added by Marc@, with the commit message "new= >> version."[2] >> =20 >> OS X Darwin has a very similar modification to ps(1), which simply s= ets >> UNLIMITED for all non-tty outputs.[3] I've chosen to respect COLUMN= S >> instead of behaving identically to Darwin here, but I don't feel str= ongly >> about that. We could match OS X for parity if that is desired. >> =20 >> [0]: https://svnweb.freebsd.org/csrg/bin/ps/ps.c?annotate=3D1065 >> [1]: https://svnweb.freebsd.org/csrg/bin/ps/ps.c?r1=3D18105&r2=3D181= 06 >> [2]: >> https://svnweb.freebsd.org/csrg/bin/ps/ps.c?r1=3D40675&r2=3D40674&pa= threv=3D40675 >> [3]: >> https://opensource.apple.com/source/adv_cmds/adv_cmds-168/ps/ps.c.au= to.html >> =20 >> PR: 217159 >> Reported by: Deepak Nagaraj >> >> Modified: >> head/bin/ps/ps.c >> >> Modified: head/bin/ps/ps.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/bin/ps/ps.c Sat Mar 4 22:23:59 2017 (r314684) >> +++ head/bin/ps/ps.c Sat Mar 4 22:38:10 2017 (r314685) >> @@ -194,6 +194,8 @@ main(int argc, char *argv[]) >> =20 >> if ((cols =3D getenv("COLUMNS")) !=3D NULL && *cols !=3D '\0') >> termwidth =3D atoi(cols); >> + else if (!isatty(STDOUT_FILENO)) >> + termwidth =3D UNLIMITED; >> else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) =3D=3D -1 &&= >> ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) =3D=3D -1 && >> ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&ws) =3D=3D -1) || >> >=20 >=20 --=20 Regards, Bryan Drewery --iCNvVh0AeaLkKqtwAFqavhhXGPHmuODwi-- --gTltGfjTpF8TIjHLg0sX0GM4Qr512rC7f Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQEcBAEBCgAGBQJYvjZnAAoJEDXXcbtuRpfPmy4IAI/QQ221scyCn/YVDRrGIqlo de6gbWzK9PX7ARLFUQHbvhTVX9jrsKFlxvagPq3iVdUOKDejgimzDafXl3w4Ya5W bZB0+uK/Laz1OeLeoS34k6kV1dEhlMhBT9ZFU0hGasA+hcWiSNAZWMoGFJAPzHqs Qj1JI+DHP7zHi8vwguXkgOorSxVvE044vXGys1w1O/HQwCEZWWa/LUA04Kp9mu6k u7GUXN4dBmpZ920vd1qX8ELSUbq+OdQV9V2LxUy1EMQvBEiK+l2ntPnhuEVrm6U1 0cK/6pMtw9lU7S6YbyGJ22lquLybbCGw3Hf+3Po7/Xxbc0o6Bo+pNamA1pXPFyM= =291A -----END PGP SIGNATURE----- --gTltGfjTpF8TIjHLg0sX0GM4Qr512rC7f--