Subject: bug#7157: df should default to -P if output is not a tty

From: Alain Knaff <[email-masked]>
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