summaryrefslogtreecommitdiff
path: root/tests/du
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-04-03 20:32:44 +0200
committerJim Meyering <meyering@redhat.com>2012-04-04 12:20:56 +0200
commite43d30eab3215bc9ff49ec7db3d3e2baa95ba070 (patch)
treeb3828ca5bdc794f9b8648af1996d2863663c8590 /tests/du
parent64ecea53d9b4c1ecbf6d02ff8c4ae98b3a82e9a2 (diff)
downloadcoreutils-e43d30eab3215bc9ff49ec7db3d3e2baa95ba070.tar.xz
tests: convert nearly all `...` expressions to $(...)
Exempt init.sh because it runs before we're assured to have a shell that groks $(...). Exempt *.mk because "$" would have to be doubled, and besides, any `...` expression in a .mk file is almost certainly evaluated before init.sh is run. Finally, also exempt the perl-based tests, because perl's `...` cannot be converted to $(...). Do that by running this command: git grep -l '`.*`' tests \ | grep -Ev 'init\.sh|\.mk$' | xargs grep -Lw perl \ | xargs perl -pi -e 's/`(.*?)`/\$($1)/g' One minor fix-up change was required after that, due to how quoting differs: diff --git a/tests/chmod/equals b/tests/chmod/equals - expected_perms=$(eval 'echo \$expected_'$dest) + expected_perms=$(eval 'echo $expected_'$dest) Another was to make these required quoting adjustments: diff --git a/tests/misc/stty b/tests/misc/stty ... - rev=$(eval echo "\\\$REV_$opt") + rev=$(eval echo "\$REV_$opt") ... - rev1=$(eval echo "\\\$REV_$opt1") - rev2=$(eval echo "\\\$REV_$opt2") + rev1=$(eval echo "\$REV_$opt1") + rev2=$(eval echo "\$REV_$opt2") Also, transform two files that were needlessly excluded above: (both use perl, but are mostly bourne shell) perl -pi -e 's/`(.*?)`/\$($1)/g' \ tests/du/long-from-unreadable tests/init.cfg
Diffstat (limited to 'tests/du')
-rwxr-xr-xtests/du/2g4
-rwxr-xr-xtests/du/8gb2
-rwxr-xr-xtests/du/basic26
-rwxr-xr-xtests/du/deref6
-rwxr-xr-xtests/du/inaccessible-cwd2
-rwxr-xr-xtests/du/long-from-unreadable6
-rwxr-xr-xtests/du/long-sloop6
-rwxr-xr-xtests/du/slink2
8 files changed, 27 insertions, 27 deletions
diff --git a/tests/du/2g b/tests/du/2g
index a901ddbe9..96cf62d7c 100755
--- a/tests/du/2g
+++ b/tests/du/2g
@@ -30,7 +30,7 @@ very_expensive_
# 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 -kP .|tail -1|sed 's/ [0-9][0-9]*%.*//;s/ *$//;s/.* //')
case "$free_kb" in
[0-9]*) ;;
*) skip_ "invalid size from df: $free_kb";;
@@ -47,7 +47,7 @@ test $min_kb -lt $free_kb ||
big=big
rm -f $big
test -t 1 || printf 'creating a 2GB file...\n'
-for i in `seq 100`; do
+for i in $(seq 100); do
# Note: 2147483648 == 2^31. Print floor(2^31/100) per iteration.
printf %21474836s x >> $big || fail=1
# On the final iteration, append the remaining 48 bytes.
diff --git a/tests/du/8gb b/tests/du/8gb
index 2028d90a0..556423e3c 100755
--- a/tests/du/8gb
+++ b/tests/du/8gb
@@ -32,7 +32,7 @@ fi
# the 'dd' command above mistakenly creates a file of length '0', yet
# doesn't fail. The root of that failure is that the ftruncate call
# returns zero but doesn't do its job. Detect this failure.
-set x `ls -gG big`
+set x $(ls -gG big)
size=$4
if test "$size" = 0; then
skip_ "cannot create a file large enough for this test
diff --git a/tests/du/basic b/tests/du/basic
index bb0980eee..d8acf6420 100755
--- a/tests/du/basic
+++ b/tests/du/basic
@@ -29,7 +29,7 @@ printf %4096s x > d/1
cp d/1 d/sub/2
-B=`stat --format=%B a/b/F`
+B=$(stat --format=%B a/b/F)
du --block-size=$B -a a > out || fail=1
echo === >> out
@@ -37,11 +37,11 @@ du --block-size=$B -a -S a >> out || fail=1
echo === >> out
du --block-size=$B -s a >> out || fail=1
-f=`stat --format=%b a/b/F`
-b=`stat --format=%b a/b`
-a=`stat --format=%b a`
-bf=`expr $b + $f`
-tot=`expr $bf + $a`
+f=$(stat --format=%b a/b/F)
+b=$(stat --format=%b a/b)
+a=$(stat --format=%b a)
+bf=$(expr $b + $f)
+tot=$(expr $bf + $a)
cat <<EOF | sed 's/ *#.*//' > exp
$f a/b/F
@@ -65,13 +65,13 @@ if is_local_dir_ .; then
echo === >> out
du --block-size=$B -S d | sort -r -k2,2 >> out || fail=1
- t2=`stat --format=%b d/sub/2`
- ts=`stat --format=%b d/sub`
- t1=`stat --format=%b d/1`
- td=`stat --format=%b d`
- tot=`expr $t1 + $t2 + $ts + $td`
- d1=`expr $td + $t1`
- s2=`expr $ts + $t2`
+ t2=$(stat --format=%b d/sub/2)
+ ts=$(stat --format=%b d/sub)
+ t1=$(stat --format=%b d/1)
+ td=$(stat --format=%b d)
+ tot=$(expr $t1 + $t2 + $ts + $td)
+ d1=$(expr $td + $t1)
+ s2=$(expr $ts + $t2)
cat <<EOF | sed 's/ *#.*//' > exp
$t2 d/sub/2
diff --git a/tests/du/deref b/tests/du/deref
index bf2ead4d7..90b765039 100755
--- a/tests/du/deref
+++ b/tests/du/deref
@@ -39,9 +39,9 @@ du -L dangle > /dev/null 2>&1 && fail=1
# du -L used to mess up, either by counting the symlink's disk space itself
# (-L should follow symlinks, not count their space)
# or (briefly in July 2010) by omitting the entry for "a".
-du_L_output=`du -L a` || fail=1
-du_lL_output=`du -lL a` || fail=1
-du_x_output=`du --exclude=dotdot a` || fail=1
+du_L_output=$(du -L a) || fail=1
+du_lL_output=$(du -lL a) || fail=1
+du_x_output=$(du --exclude=dotdot a) || fail=1
test "X$du_L_output" = "X$du_x_output" || fail=1
test "X$du_lL_output" = "X$du_x_output" || fail=1
diff --git a/tests/du/inaccessible-cwd b/tests/du/inaccessible-cwd
index 39e62584d..bfc8cf92e 100755
--- a/tests/du/inaccessible-cwd
+++ b/tests/du/inaccessible-cwd
@@ -29,7 +29,7 @@ require_openat_support_
skip_if_root_
-cwd=`pwd`
+cwd=$(pwd)
mkdir -p no-x a/b || framework_failure_
cd no-x || framework_failure_
chmod 0 . || framework_failure_
diff --git a/tests/du/long-from-unreadable b/tests/du/long-from-unreadable
index 10864e00e..7fc129c17 100755
--- a/tests/du/long-from-unreadable
+++ b/tests/du/long-from-unreadable
@@ -36,11 +36,11 @@ if test ! -d $proc_file; then
skip_ 'This test would fail, since your system lacks /proc support.'
fi
-dir=`printf '%200s\n' ' '|tr ' ' x`
+dir=$(printf '%200s\n' ' '|tr ' ' x)
# Construct a hierarchy containing a relative file with a name
# longer than PATH_MAX.
-# for i in `seq 52`; do
+# for i in $(seq 52); do
# mkdir $dir || framework_failure_
# cd $dir || framework_failure_
# done
@@ -51,7 +51,7 @@ dir=`printf '%200s\n' ' '|tr ' ' x`
# cannot access parent directories:
# (all on one line).
-cwd=`pwd`
+cwd=$(pwd)
# Use perl instead:
: ${PERL=perl}
$PERL \
diff --git a/tests/du/long-sloop b/tests/du/long-sloop
index 78926d38f..f9e70ad00 100755
--- a/tests/du/long-sloop
+++ b/tests/du/long-sloop
@@ -29,11 +29,11 @@ print_ver_ du
# in a single directory.
n=400
-dir_list=`seq $n`
+dir_list=$(seq $n)
mkdir $dir_list || framework_failure_
file=1
i_minus_1=0
-for i in $dir_list `expr $n + 1`; do
+for i in $dir_list $(expr $n + 1); do
case $i_minus_1 in
0) ;;
*)
@@ -56,7 +56,7 @@ echo foo > $i
cat $file > /dev/null 2> err &&
skip_ 'Your system appears to be able to handle more than $n symlinks
in file name resolution'
-too_many=`sed 's/.*: //' err`
+too_many=$(sed 's/.*: //' err)
# With coreutils-5.93 there was no failure.
diff --git a/tests/du/slink b/tests/du/slink
index 1f8429171..674e6a224 100755
--- a/tests/du/slink
+++ b/tests/du/slink
@@ -32,7 +32,7 @@ fi
symlink_name_lengths='1 15 16 31 32 59 60 63 64 127 128 255 256 511 512 1024'
for len in $symlink_name_lengths; do
- name=`seq 1 $len|tr -c x y |head -c$len`
+ name=$(seq 1 $len|tr -c x y |head -c$len)
# Record the names of symlinks that are successfully created.
ln -fs $name $len > /dev/null 2>&1 \
&& symlinks="$symlinks $len"