From owner-freebsd-bugs@FreeBSD.ORG Thu Dec 22 11:50:09 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6334716A41F for ; Thu, 22 Dec 2005 11:50:09 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 73F6543D6D for ; Thu, 22 Dec 2005 11:50:08 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id jBMBo8va078139 for ; Thu, 22 Dec 2005 11:50:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id jBMBo8im078138; Thu, 22 Dec 2005 11:50:08 GMT (envelope-from gnats) Date: Thu, 22 Dec 2005 11:50:08 GMT Message-Id: <200512221150.jBMBo8im078138@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Vadim Goncharov Cc: Subject: Re: bin/90690: ps(1) errorneously respects terminal column settings when output is not to a terminal X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Vadim Goncharov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Dec 2005 11:50:09 -0000 The following reply was made to PR bin/90690; it has been noted by GNATS. From: Vadim Goncharov To: bug-followup@FreeBSD.org Cc: Oliver Fromme Subject: Re: bin/90690: ps(1) errorneously respects terminal column settings when output is not to a terminal Date: Thu, 22 Dec 2005 05:26:00 +0600 Hello Oliver, Wednesday, December 21, 2005, 11:00:06 PM, you wrote: OF> What you describe is standard BSD ps(1) behaviour, as is OF> documented in the manual page. It's not clarified there in the case of redirection. OF> Basically, the intent is that, when you redirect ps(1) output OF> somewhere (to a file or pipe), you get exactly the same that OF> is displayed on the screen. This is counter-intuitive. If I am redirecting output to file, I expect to see result somewhat later. It's somewhat strange that result will be not stable constant, but unpredictable, depending on terminal settings at the moment of running. OF> The rules are: If ps(1) is running in a terminal, it's width OF> is used. If it's not running in a terminal (e.g. via a cron OF> job) or the width cannot be determined, the default is 80 OF> columns. To determine the terminal width, any one of stdout, OF> stderr or stdin is used -- therefore, to let ps(1) ignore the OF> terminal width, you have to redirect stderr and stdin. OF> If you specify the -w option once, the limit is expanded to OF> 132 columns (unless your terminal width is already larger OF> than that). Finally, if you specify -w twice, the width is OF> assumed to be unlimited. Compare it with ls(1) behavior. If output is not to a terminal, ls behaves as expected, not using any terminal crap. And this is clearly documented in ls man page. OF> When you use ps(1) in a pipe to grep for things, you should OF> always use the -ww options. Also note that newer versions of FreeBSD (>> 4.x) have a pgrep(1) command which can be used OF> as a convenient replacement for ps | grep pipes. Yes, but grep is not the only thing used with redirection. Moreover, I've tried to run "ps aux > myprocs.txt" on Linux (Slackware 10) and it worked as I expected - full lines in file while on terminal they were truncated (and linux have pgrep(1) also). So, I insist that ps(1) behavior should be corrected. OK, developers may have another opinion, but in that case at least ps man page should be fixed, adding a paragraph clarifying this, somewhat like what you explained earlier in this post. -- WBR, Vadim Goncharov FidoNet 2:5005/106.426 ICQ#166852181