GNU bug report logs - #7157
df should default to -P if output is not a tty

Previous Next

Package: coreutils;

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.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alain Knaff <alain <at> knaff.lu>
To: bug-coreutils <at> gnu.org
Subject: df should default to -P if output is not a tty
Date: Mon, 04 Oct 2010 11:44:15 +0200
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




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.