GNU bug report logs -
#7157
df should default to -P if output is not a tty
Previous Next
Reported by: Alain Knaff <alain <at> knaff.lu>
Date: Mon, 4 Oct 2010 12:47:01 UTC
Severity: normal
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7157 in the body.
You can then email your comments to 7157 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#7157
; Package
coreutils
.
(Mon, 04 Oct 2010 12:47:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alain Knaff <alain <at> knaff.lu>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Mon, 04 Oct 2010 12:47:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#7157
; Package
coreutils
.
(Mon, 04 Oct 2010 14:28:03 GMT)
Full text and
rfc822 format available.
Message #8 received at 7157 <at> debbugs.gnu.org (full text, mbox):
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 <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#7157
; Package
coreutils
.
(Mon, 04 Oct 2010 15:04:03 GMT)
Full text and
rfc822 format available.
Message #11 received at 7157 <at> debbugs.gnu.org (full text, mbox):
[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 <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#7157
; Package
coreutils
.
(Mon, 04 Oct 2010 16:30:04 GMT)
Full text and
rfc822 format available.
Message #14 received at 7157 <at> debbugs.gnu.org (full text, mbox):
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
Reply sent
to
Pádraig Brady <P <at> draigBrady.com>
:
You have taken responsibility.
(Thu, 24 Mar 2011 00:15:04 GMT)
Full text and
rfc822 format available.
Notification sent
to
Alain Knaff <alain <at> knaff.lu>
:
bug acknowledged by developer.
(Thu, 24 Mar 2011 00:15:04 GMT)
Full text and
rfc822 format available.
Message #19 received at 7157-done <at> debbugs.gnu.org (full text, mbox):
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
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 21 Apr 2011 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 66 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.