mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-02-11 09:51:56 +02:00
maint: simplify parsing df's output in shell scripts
Avoid complicated and error-prone parsing of df's output via sed(1), cut(1), etc., and instead use df's more modern --output option. * src/ioblksize.h (in a comment): Simplify the extraction of the device name of the mounted file system from df's output. * tests/dd/skip-seek-past-dev.sh: Likewise. * tests/du/2g.sh: Likewise for the 'avail' column here. Also avoid the deprecated use of "tail -NUM". * tests/misc/stat-mount.sh: While at it, remove the determination of the mount point of "." via df(1) plus sed(1) as it is unused since commit v8.5-159-gf57cb37 anyway. Instead, improve this test by verifying that the output of "stat -c%m ." at least starts with a slash '/'.
This commit is contained in:
@@ -27,10 +27,7 @@ very_expensive_
|
||||
|
||||
# Get number of free kilobytes on current partition, so we can
|
||||
# skip this test if there is insufficient free space.
|
||||
|
||||
# This technique relies on the fact that the 'Available' kilobyte
|
||||
# count is the number just before the one with a trailing '%'.
|
||||
free_kb=$(df -kP .|tail -1|sed 's/ [0-9][0-9]*%.*//;s/ *$//;s/.* //')
|
||||
free_kb=$(df -k --output=avail . | tail -n1)
|
||||
case "$free_kb" in
|
||||
[0-9]*) ;;
|
||||
*) skip_ "invalid size from df: $free_kb";;
|
||||
|
||||
Reference in New Issue
Block a user