fa.openbsd.tech
[Top] [All Lists]

Re: [patch] ps.c ps.1 Disregard terminal width when STDOUT is not a tty

Subject: Re: [patch] ps.c ps.1 Disregard terminal width when STDOUT is not a tty (take 2)
From: Hannah Schroeter <hannah@xxxxxxxxxx>
Date: Mon, 21 Jul 2008 21:08:38 UTC
Newsgroups: fa.openbsd.tech

Hi!

On Mon, Jul 21, 2008 at 10:58:49AM -0400, Nick Guenther wrote:
>On Mon, Jul 21, 2008 at 8:32 AM, Hannah Schroeter <hannah@xxxxxxxxxx> wrote:
>> On Mon, Jul 21, 2008 at 12:18:04PM +1000, Evan Clarke wrote:
>>>On 21/07/2008, Theo de Raadt <deraadt@xxxxxxxxxxxxxxx> wrote:
>>>> I don't particularily like this.  I think you should use the option "ww".

>>>>     -w      Use 132 columns to display information, instead of the default,
>>>>             which is the window size.  If the -w option is specified more
>>>>             than once, ps will use as many columns as necessary without re-
>>>>             gard for window size.

>>>> As in, this is already a solved problem.

>>>You do raise a valid point.  My main reason for the patch is that I
>>>have a couple of scripts that I don't control, that assume the ww on
>>>STDOUT!=tty, and break if it isn't present - I am assuming because the
>>>GNU tools (and maybe others) do this.

>>>This patch stops scripts behaviour from being dependant on the
>>>terminal size - it adds a certain level of certainty on the output, in
>>>a similar way to how ls changes behaviour of its output if it is
>>>piping.

>> I wouldn't like your patch.

>> No way to tell ps to create terminal width output for ps ... | grep
>> pipes any more.

>Huh? How do you use that? Isn't the point that grep searches records
>of related information? Why would you ever want it to be dealing with
>results split across lines?
>-Nick

Huh?

ps never wraps lines (never splits one logical line into several
physical ones). It now crops the lines to the terminal's line width by
default, or to 132 with one w option, or doesn't crop (but outputs long
lines) at all with two w options.

So ps ... (without any w option) | grep yields terminal width output
without the discussed patch. With the discussed patch, it'd yield long
lines and there'd be no option to tell ps to create terminal width lines
in the first place.

Kind regards,

Hannah.


<Prev in Thread] Current Thread [Next in Thread>