From 9c128c0e4943421a73fb0cde4b06a2baa751fdeb Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Fri, 4 Jul 2014 01:54:45 +0200 Subject: 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 '/'. --- tests/dd/skip-seek-past-dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/dd') diff --git a/tests/dd/skip-seek-past-dev.sh b/tests/dd/skip-seek-past-dev.sh index caa2314df..5eb7ab5ac 100755 --- a/tests/dd/skip-seek-past-dev.sh +++ b/tests/dd/skip-seek-past-dev.sh @@ -33,7 +33,7 @@ get_device_size() { # Get path to device the current dir is on. # Note df can only get fs size, not device size. -device=$(df -P . | tail -n1 | cut -d' ' -f1) || framework_failure_ +device=$(df --output=source . | tail -n1) || framework_failure_ dev_size=$(get_device_size "$device") || skip_ "failed to determine size of $device" -- cgit v1.2.3-70-g09d2