summaryrefslogtreecommitdiff
path: root/tests/du/2g.sh
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2014-07-04 01:54:45 +0200
committerBernhard Voelker <mail@bernhard-voelker.de>2014-07-04 01:54:45 +0200
commit9c128c0e4943421a73fb0cde4b06a2baa751fdeb (patch)
tree26adc0e76cd686e45fedbf9794d93a7b2f951607 /tests/du/2g.sh
parent8e2219b09c513e6e0e8f83cca73baa05cd876f12 (diff)
downloadcoreutils-9c128c0e4943421a73fb0cde4b06a2baa751fdeb.tar.xz
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 '/'.
Diffstat (limited to 'tests/du/2g.sh')
-rwxr-xr-xtests/du/2g.sh5
1 files changed, 1 insertions, 4 deletions
diff --git a/tests/du/2g.sh b/tests/du/2g.sh
index cfd1fc464..f766d4d9d 100755
--- a/tests/du/2g.sh
+++ b/tests/du/2g.sh
@@ -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";;