From unknown Sun Jun 22 17:12:10 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#7157 <7157@debbugs.gnu.org> To: bug#7157 <7157@debbugs.gnu.org> Subject: Status: df should default to -P if output is not a tty Reply-To: bug#7157 <7157@debbugs.gnu.org> Date: Mon, 23 Jun 2025 00:12:10 +0000 retitle 7157 df should default to -P if output is not a tty reassign 7157 coreutils submitter 7157 Alain Knaff severity 7157 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 04 08:46:34 2010 Received: (at submit) by debbugs.gnu.org; 4 Oct 2010 12:46:34 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P2kR4-0000PB-R5 for submit@debbugs.gnu.org; Mon, 04 Oct 2010 08:46:34 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P2hYv-0006os-Cv for submit@debbugs.gnu.org; Mon, 04 Oct 2010 05:42:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P2hbu-0002TZ-39 for submit@debbugs.gnu.org; Mon, 04 Oct 2010 05:45:31 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:54358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P2hbt-0002Su-1B for submit@debbugs.gnu.org; Mon, 04 Oct 2010 05:45:30 -0400 Received: from [140.186.70.92] (port=55326 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P2hbp-0006B3-9k for bug-coreutils@gnu.org; Mon, 04 Oct 2010 05:45:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P2hao-00027x-LQ for bug-coreutils@gnu.org; Mon, 04 Oct 2010 05:44:23 -0400 Received: from crmm.lgl.lu ([158.64.72.228]:57726 helo=lll.lu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P2hao-00027I-Dg for bug-coreutils@gnu.org; Mon, 04 Oct 2010 05:44:22 -0400 Received: from [192.168.37.143] (ses [212.56.227.238]) (authenticated bits=0) by lll.lu (8.14.3/8.14.3/Debian-6) with ESMTP id o949iF1n001121 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 4 Oct 2010 11:44:17 +0200 Message-ID: <4CA9A1EF.80904@knaff.lu> Date: Mon, 04 Oct 2010 11:44:15 +0200 From: Alain Knaff User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Lightning/1.0b2 Thunderbird/3.1.3 MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: df should default to -P if output is not a tty Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.7 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 04 Oct 2010 08:46:29 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.7 (-----) Hello, We just had a case where an overfull disk went unnoticed by logwatch. The reason turned out to be its long device name (/dev/mapper /VolGroup00-LogVol00), which caused df to break the line, messing up the column count. Indeed, logwatch looks for the use% in the fifth field, but due to this line breaking, the use% for this disk ended up in the _fourth_ field of the next line instead. There is an option to prevent this behavior (-P), but apparently the logwatch authors were not aware of it. Understandably, I might say, because if their test cases happen to only have disks with short names, they'll never stumble upon this. So, in the name of the "principle of least surprise" wouldn't it be possible to make -P the default if the output is not a tty (and add an additional flag for those rare cases where this line-breaking behavior is actually wanted on non-tty's) Other utilities, such as Debian's dpkg -l, also default to this behavior (trimming lines to window width if output is a tty, and not trimming it if output is not a tty). Same thing for ls (column output on a tty, one file-name per line on non-tty) The problem was observed on version coreutils-8.4-8.fc13.i686: # df | cat Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 66688656 47463424 15782956 76% / /dev/cciss/c0d0p1 197546 19124 168223 11% /boot tmpfs 517468 12 517456 1% /dev/shm Thanks, Alain From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 04 10:27:18 2010 Received: (at 7157) by debbugs.gnu.org; 4 Oct 2010 14:27:18 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P2m0c-0003G6-4F for submit@debbugs.gnu.org; Mon, 04 Oct 2010 10:27:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P2m0X-0003FP-S5 for 7157@debbugs.gnu.org; Mon, 04 Oct 2010 10:27:15 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o94EUIMQ010376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 4 Oct 2010 10:30:18 -0400 Received: from [10.3.113.30] (ovpn-113-30.phx2.redhat.com [10.3.113.30]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o94EUHxl000954; Mon, 4 Oct 2010 10:30:18 -0400 Message-ID: <4CA9E4F8.30203@redhat.com> Date: Mon, 04 Oct 2010 08:30:16 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.4 MIME-Version: 1.0 To: Alain Knaff Subject: Re: bug#7157: df should default to -P if output is not a tty References: <4CA9A1EF.80904@knaff.lu> In-Reply-To: <4CA9A1EF.80904@knaff.lu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-Spam-Score: -10.1 (----------) X-Debbugs-Envelope-To: 7157 Cc: 7157@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.1 (----------) On 10/04/2010 03:44 AM, Alain Knaff wrote: > There is an option to prevent this behavior (-P), but apparently the > logwatch authors were not aware of it. Understandably, I might say, > because if their test cases happen to only have disks with short names, > they'll never stumble upon this. Thanks for the report. However, I'm reluctant to make the change, on the grounds that df -P is documented by POSIX: http://www.opengroup.org/onlinepubs/9699919799/utilities/df.html Anyone that wants portable output MUST use -P, because POSIX explicitly implies that not using -P leads to implementation-defined formatting, which is therefore not machine-parseable. Furthermore, GNU Coding Standards strongly discourage making behavior dependent on whether stdout is a tty. Yes, some actions, like ls behavior, are mandated by POSIX, and some actions, like --color=auto only make sense with a tty check, but we should not be adding new exceptions without good cause. One thing that might be possible, however, is to improve df output to adjust column alignment if $COLUMNS is not set (or is set to something large), so as to avoid breaking lines in the case where the output is usable in a long-line context. But this still doesn't help the case that logwatch should have been using -P in the first place. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 04 11:03:40 2010 Received: (at 7157) by debbugs.gnu.org; 4 Oct 2010 15:03:40 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P2mZo-0005On-3o for submit@debbugs.gnu.org; Mon, 04 Oct 2010 11:03:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P2mZj-0005O8-P2 for 7157@debbugs.gnu.org; Mon, 04 Oct 2010 11:03:37 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o94F6edb006010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 4 Oct 2010 11:06:41 -0400 Received: from [10.3.113.30] (ovpn-113-30.phx2.redhat.com [10.3.113.30]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o94F6d5H009412; Mon, 4 Oct 2010 11:06:40 -0400 Message-ID: <4CA9ED7F.8090608@redhat.com> Date: Mon, 04 Oct 2010 09:06:39 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.4 MIME-Version: 1.0 To: Alain Knaff , 7157@debbugs.gnu.org Subject: Re: bug#7157: df should default to -P if output is not a tty References: <4CA9A1EF.80904@knaff.lu> <4CA9E4F8.30203@redhat.com> <4CA9EA8C.3020608@knaff.lu> In-Reply-To: <4CA9EA8C.3020608@knaff.lu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -10.1 (----------) X-Debbugs-Envelope-To: 7157 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.1 (----------) [please keep the list in the loop] On 10/04/2010 08:54 AM, Alain Knaff wrote: >> One thing that might be possible, however, is to improve df output to >> adjust column alignment if $COLUMNS > > Rather than using $COLUMNS (which is not set by all shells...), it might > be preferable to do an ioctl(1, TIOCGWINSZ, ...) instead. Indeed, the > ioctl returns the window size as it is now (even if it has been resized). > That is what ls does, in any case. Yep, for consistency among coreutils, the ioctl approach is definitely best. > >> is not set (or is set to something >> large), so as to avoid breaking lines in the case where the output is >> usable in a long-line context. But this still doesn't help the case >> that logwatch should have been using -P in the first place. >> > > Agreed. I now also reported the problem to Kirk Bauer from logwatch. Glad to hear it. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 04 12:29:08 2010 Received: (at 7157) by debbugs.gnu.org; 4 Oct 2010 16:29:08 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P2nuV-0007nd-Ns for submit@debbugs.gnu.org; Mon, 04 Oct 2010 12:29:08 -0400 Received: from crmm.lgl.lu ([158.64.72.228] helo=lll.lu) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P2mdj-0005cZ-Dy for 7157@debbugs.gnu.org; Mon, 04 Oct 2010 11:07:44 -0400 Received: from [192.168.37.143] (ses [212.56.227.238]) (authenticated bits=0) by lll.lu (8.14.3/8.14.3/Debian-6) with ESMTP id o94FAlbf030696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 4 Oct 2010 17:10:49 +0200 Message-ID: <4CA9EE77.90509@knaff.lu> Date: Mon, 04 Oct 2010 17:10:47 +0200 From: Alain Knaff User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Lightning/1.0b2 Thunderbird/3.1.3 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#7157: df should default to -P if output is not a tty References: <4CA9A1EF.80904@knaff.lu> <4CA9E4F8.30203@redhat.com> <4CA9EA8C.3020608@knaff.lu> <4CA9ED7F.8090608@redhat.com> In-Reply-To: <4CA9ED7F.8090608@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: 7157 X-Mailman-Approved-At: Mon, 04 Oct 2010 12:29:06 -0400 Cc: 7157@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.6 (---) On 04/10/10 17:06, Eric Blake wrote: > [please keep the list in the loop] > > On 10/04/2010 08:54 AM, Alain Knaff wrote: >>> One thing that might be possible, however, is to improve df output to >>> adjust column alignment if $COLUMNS >> >> Rather than using $COLUMNS (which is not set by all shells...), it might >> be preferable to do an ioctl(1, TIOCGWINSZ, ...) instead. Indeed, the >> ioctl returns the window size as it is now (even if it has been resized). >> That is what ls does, in any case. > > Yep, for consistency among coreutils, the ioctl approach is definitely best. ... and interestingly enough, the ioctl has the "advantage" of telling us whether the output is indeed a tty or not (it fails with EINVAL if it is not). AFAIU, this is how ls does the trick of finding out whether stdout is a tty or not. In a way, a non-tty could be considered equivalent to an infinetly wide window. > >> >>> is not set (or is set to something >>> large), so as to avoid breaking lines in the case where the output is >>> usable in a long-line context. But this still doesn't help the case >>> that logwatch should have been using -P in the first place. >>> >> >> Agreed. I now also reported the problem to Kirk Bauer from logwatch. > > Glad to hear it. > Regards, Alain From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 23 20:14:09 2011 Received: (at 7157-done) by debbugs.gnu.org; 24 Mar 2011 00:14:09 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2YBl-0002MA-Fk for submit@debbugs.gnu.org; Wed, 23 Mar 2011 20:14:09 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1Q2YBh-0002LN-1S for 7157-done@debbugs.gnu.org; Wed, 23 Mar 2011 20:14:06 -0400 Received: (qmail 34093 invoked from network); 24 Mar 2011 00:13:58 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 24 Mar 2011 00:13:58 -0000 Message-ID: <4D8A8C3C.10403@draigBrady.com> Date: Thu, 24 Mar 2011 00:11:40 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: 7157-done@debbugs.gnu.org, 6511-done@debbugs.gnu.org Subject: df no longer wraps lines X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 7157-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) Since I've just changed df to no longer split entries with long device names over two lines (since it now aligns columns consistently), I'm closing these. cheers, Pádraig From unknown Sun Jun 22 17:12:10 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 21 Apr 2011 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator