Bug #827
closed(GNU) df gives multiline output even when piped
0%
Description
When 'df' program encounters "long" device or mountpoint names, it makes the terminal output prettier by splitting such lines into two and space-padding the output.
However, and many scripts historically depended on it, 'df' produces a single line per filesystem when piped (to grep, awk or whatever). This works with both Solaris and Linux (GNU?) df variants.
However, the /usr/gnu/bin/df in OI_148a LiveUSB lacks this feature:
root@openindiana:~# df -k /a
Filesystem 1K-blocks Used Available Use% Mounted on
rpool/ROOT/openindiana
16717979 2968243 13749736 18% /a
root@openindiana:~# df -k | grep openindiana
rpool/ROOT/openindiana
This is a bug and should be fixed - it can break an indeterminate number of scripts and programs which rely on parsing the 'df' output.
//Jim Klimov
Updated by Jim Klimov about 11 years ago
Tested after completed installation: the same (buggy) GNU df variant is installed on hard disk from oi_148a LiveUSB.
Updated by Julian Wiesener about 11 years ago
- Category set to 10
- Assignee set to OI SFW
Workarround: Do not use GNU df for your shell scripts
root@laphroaig:~# /usr/gnu/bin/df -k | grep -i long_long
rpool/filesystem_with_long_long_long_long_long_long_long_long_name
root@laphroaig:~# /usr/bin/df -k | grep -i long_long
rpool/filesystem_with_long_long_long_long_long_long_long_long_name 76382208 21 24797798 1% /mnt
Updated by Jim Klimov about 11 years ago
Workaround is relatively suitable, except:
1) Many (legacy/packaged) scripts I've encountered and written rely on system PATH.
If OI sets by default that GNU/bin would be before system /usr/bin, and those utilities don't work properly, it is an issue. Changing all these scripts on each installation (or changing the /etc/profile and wherever else the GNU path is prepended) is not practical.
2) In this particular case, the scripts that broke for me are portable between RHEL and (Open)Solaris, and in both platforms the default "df" worked properly. I'm pretty sure that Linux "df" is a GNU "df", so I view that change in behavior as a regression/incompatibility/whatever.
//Jim
Updated by Ken Mays over 10 years ago
- Due date set to 2011-09-14
- Assignee changed from OI SFW to OI Userland
- Target version set to oi_151_stable
- Estimated time set to 8.00 h
- Difficulty set to Medium
- Tags set to needs-triage
Updated by Ken Mays over 10 years ago
- Status changed from New to Resolved
file/gnu-coreutils@8.5,5.11-0.151.1:20110910T035245Z
kmays ~ (spiritworld): df --version
df (GNU coreutils) 8.5
...
kmays ~ (spiritworld): df -k |grep spirit
data/zones/spirited/ROOT/zbe-1
data/zones/spirited/ROOT/dc
data/zones/spirited/ROOT/projects
data/zones/spirited/ROOT/projects/build_trees
data/zones/spirited/ROOT/projects/build_trees/oi-oi_151a
data/zones/spirited/ROOT/projects/sustaining
data/zones/spirited/ROOT/projects/sustaining/oi_151a
data/zones/spirited/ROOT/repos
data/zones/spirited/ROOT/rpool
data/share/us/spiritworld/ga/homes
GNU df is within specs. Possibly, upgrade later.