From owner-freebsd-questions Fri Aug 17 17:57:14 2001 Delivered-To: freebsd-questions@freebsd.org Received: from scaup.mail.pas.earthlink.net (scaup.mail.pas.earthlink.net [207.217.121.49]) by hub.freebsd.org (Postfix) with ESMTP id 9A1A137B407 for ; Fri, 17 Aug 2001 17:57:10 -0700 (PDT) (envelope-from cjc@earthlink.net) Received: from blossom.cjclark.org (dialup-209.245.140.149.Dial1.SanJose1.Level3.net [209.245.140.149]) by scaup.mail.pas.earthlink.net (EL-8_9_3_3/8.9.3) with ESMTP id RAA08285; Fri, 17 Aug 2001 17:57:07 -0700 (PDT) Received: (from cjc@localhost) by blossom.cjclark.org (8.11.4/8.11.3) id f7I0v4Y02541; Fri, 17 Aug 2001 17:57:04 -0700 (PDT) (envelope-from cjc) Date: Fri, 17 Aug 2001 17:57:04 -0700 From: "Crist J. Clark" To: Kevin Oberman Cc: parv , cjclark@alum.mit.edu, f-q Subject: Re: ps & terminal width sensitivity inside a script Message-ID: <20010817175704.D306@blossom.cjclark.org> Reply-To: cjclark@alum.mit.edu References: <20010817020514.B25092@moo.holy.cow> <200108172113.f7HLDuR30581@ptavv.es.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200108172113.f7HLDuR30581@ptavv.es.net>; from oberman@es.net on Fri, Aug 17, 2001 at 02:13:55PM -0700 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Aug 17, 2001 at 02:13:55PM -0700, Kevin Oberman wrote: > > Date: Fri, 17 Aug 2001 02:05:14 -0400 > > From: parv > > Sender: owner-freebsd-questions@FreeBSD.ORG > > > > this was, on the fateful occasion around Aug 16 21:59 -0400, > > sent by Crist J. Clark > > > > > > On Thu, Aug 16, 2001 at 07:26:05PM -0400, parv wrote: > > > > why is ps sensitive to terminal width even when used inside a shell > > > > script? > > > > > > Just 'cause. > > > > what a dissapointment! i was expecting little more resonable > > reasons(s). > > OK. Here is something more reasonable (but just a bit). > > ps(1) is a very old utility dating at least back to the earliest days of > Unix. (It might even date to Multics, but I can't say for sure.) Back > in the days of Teletypes and big honkin' printers. Back in the days > when teletypes were 80 characters wide and line printers 132 > characters wide. Back in the days when there was nothing else. > > There was no termcap or terminfo. There were no windows or even > CRTs. Since everything was one or the other, ps(1) was written with > three options, default, w, and ww at 80, 132, and unlimited width, > respectively. Since LOTS of people wrote aliases and shell scripts that > were linked to this hard-coded behavior, the very idea of changing it > was met by screams of protest, so that's where we still are. Nit pick. The existing ps(1) definately does understand terminal width. The actual options are, - default: Get the width of the terminal and use the terminal width - 1. If we cannot get the terminal width, fall back to 80 - 1 columns. - w: Force lines to 132 - 1 characters. - ww: Unlimited line length. For our original poster, the ps(1) command does an ioctl(2) call on stdin, stderr, and stdin to find the terminal width. Thus, ps(1) should be able to find out your terminal width whenever those are attached to your terminal. -- Crist J. Clark cjclark@alum.mit.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message