From e43d30eab3215bc9ff49ec7db3d3e2baa95ba070 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 3 Apr 2012 20:32:44 +0200 Subject: 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 --- tests/cp/acl | 10 +++++----- tests/cp/cp-a-selinux | 2 +- tests/cp/cp-mv-backup | 2 +- tests/cp/cp-mv-enotsup-xattr | 2 +- tests/cp/cp-parents | 10 +++++----- tests/cp/fail-perm | 2 +- tests/cp/fiemap-empty | 2 +- tests/cp/file-perm-race | 2 +- tests/cp/link-preserve | 26 +++++++++++++------------- tests/cp/link-symlink | 4 ++-- tests/cp/no-deref-link1 | 2 +- tests/cp/no-deref-link2 | 2 +- tests/cp/no-deref-link3 | 2 +- tests/cp/parent-perm-race | 2 +- tests/cp/perm | 4 ++-- tests/cp/preserve-gid | 2 +- tests/cp/preserve-link | 2 +- tests/cp/r-vs-symlink | 2 +- tests/cp/same-file | 2 +- tests/cp/sparse | 4 ++-- tests/cp/special-bits | 12 ++++++------ tests/cp/symlink-slash | 2 +- 22 files changed, 50 insertions(+), 50 deletions(-) (limited to 'tests/cp') diff --git a/tests/cp/acl b/tests/cp/acl index 94b7af69b..26a7f420a 100755 --- a/tests/cp/acl +++ b/tests/cp/acl @@ -31,22 +31,22 @@ touch a/file || framework_failure_ # Ensure that setfacl and getfacl work on this file system. skip=no -acl1=`cd a && getfacl file` || skip=yes +acl1=$(cd a && getfacl file) || skip=yes setfacl -m user:bin:rw- a/file 2> /dev/null || skip=yes test $skip = yes && skip_ "'.' is not on a suitable file system for this test" # copy a file without preserving permissions cp a/file b/ || fail=1 -acl2=`cd b && getfacl file` || framework_failure_ +acl2=$(cd b && getfacl file) || framework_failure_ test "$acl1" = "$acl2" || fail=1 # Update with acl set above -acl1=`cd a && getfacl file` || framework_failure_ +acl1=$(cd a && getfacl file) || framework_failure_ # copy a file, preserving permissions cp -p a/file b/ || fail=1 -acl2=`cd b && getfacl file` || framework_failure_ +acl2=$(cd b && getfacl file) || framework_failure_ test "$acl1" = "$acl2" || fail=1 # copy a file, preserving permissions, with --attributes-only @@ -54,7 +54,7 @@ echo > a/file || framework_failure_ # add some data test -s a/file || framework_failure_ cp -p --attributes-only a/file b/ || fail=1 test -s b/file && fail=1 -acl2=`cd b && getfacl file` || framework_failure_ +acl2=$(cd b && getfacl file) || framework_failure_ test "$acl1" = "$acl2" || fail=1 Exit $fail diff --git a/tests/cp/cp-a-selinux b/tests/cp/cp-a-selinux index 11758170d..b85298488 100755 --- a/tests/cp/cp-a-selinux +++ b/tests/cp/cp-a-selinux @@ -24,7 +24,7 @@ print_ver_ cp require_root_ require_selinux_ -cwd=`pwd` +cwd=$(pwd) cleanup_() { cd /; umount "$cwd/mnt"; } # This context is special: it works even when mcstransd isn't running. diff --git a/tests/cp/cp-mv-backup b/tests/cp/cp-mv-backup index 3e6b6ff90..030f722dc 100755 --- a/tests/cp/cp-mv-backup +++ b/tests/cp/cp-mv-backup @@ -35,7 +35,7 @@ for prog in cp mv; do for opt in none off numbered t existing nil simple never; do touch $initial_files $prog --backup=$opt x y || fail=1 - echo $initial_files $opt: `ls [xy]*`; rm -f x y y~ y.~?~ + echo $initial_files $opt: $(ls [xy]*); rm -f x y y~ y.~?~ done done done diff --git a/tests/cp/cp-mv-enotsup-xattr b/tests/cp/cp-mv-enotsup-xattr index 76ede2e3e..66e54cf11 100755 --- a/tests/cp/cp-mv-enotsup-xattr +++ b/tests/cp/cp-mv-enotsup-xattr @@ -23,7 +23,7 @@ print_ver_ cp mv require_root_ -cwd=`pwd` +cwd=$(pwd) cleanup_() { cd /; umount "$cwd/noxattr"; umount "$cwd/xattr"; } skip=0 diff --git a/tests/cp/cp-parents b/tests/cp/cp-parents index 85fccd63b..b325c722b 100755 --- a/tests/cp/cp-parents +++ b/tests/cp/cp-parents @@ -49,10 +49,10 @@ test -d d/f && fail=1 chmod go=w d/a || framework_failure_ cp -a --parents d/a/b/c e || fail=1 cp -a --parents sym/b/c g || fail=1 -p=`ls -ld e/d|cut -b-10`; case $p in drwxr-xr-x);; *) fail=1;; esac -p=`ls -ld e/d/a|cut -b-10`; case $p in drwx-w--w-);; *) fail=1;; esac -p=`ls -ld g/sym|cut -b-10`; case $p in drwx-w--w-);; *) fail=1;; esac -p=`ls -ld e/d/a/b/c|cut -b-10`; case $p in drwxr-xr-x);; *) fail=1;; esac -p=`ls -ld g/sym/b/c|cut -b-10`; case $p in drwxr-xr-x);; *) fail=1;; esac +p=$(ls -ld e/d|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac +p=$(ls -ld e/d/a|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac +p=$(ls -ld g/sym|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac +p=$(ls -ld e/d/a/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac +p=$(ls -ld g/sym/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac Exit $fail diff --git a/tests/cp/fail-perm b/tests/cp/fail-perm index 3835f6b0f..2c37d6fb1 100755 --- a/tests/cp/fail-perm +++ b/tests/cp/fail-perm @@ -31,7 +31,7 @@ cp -pR D DD > /dev/null 2>&1 && fail=1 # Permissions on DD must be 'dr-x------' -mode=`ls -ld DD|cut -b-10` +mode=$(ls -ld DD|cut -b-10) test "$mode" = dr-x------ || fail=1 chmod 0 D diff --git a/tests/cp/fiemap-empty b/tests/cp/fiemap-empty index efa4b660d..4ba4ee30e 100755 --- a/tests/cp/fiemap-empty +++ b/tests/cp/fiemap-empty @@ -29,7 +29,7 @@ fiemap_capable_ fiemap_chk || skip_ 'this file system lacks FIEMAP support' rm fiemap_chk -# TODO: rather than requiring `fallocate`, possible add +# TODO: rather than requiring $(fallocate), possible add # this functionality to truncate --alloc fallocate --help >/dev/null || skip_ 'The fallocate utility is required' fallocate -l 1 -n falloc.test || diff --git a/tests/cp/file-perm-race b/tests/cp/file-perm-race index 46db6f974..fbc9a86eb 100755 --- a/tests/cp/file-perm-race +++ b/tests/cp/file-perm-race @@ -46,7 +46,7 @@ cp_pid=$! echo foo ) >fifo -case `cat ls.out` in +case $(cat ls.out) in -???------*) ;; *) fail=1;; esac diff --git a/tests/cp/link-preserve b/tests/cp/link-preserve index 785c9e40a..9ca1705f5 100755 --- a/tests/cp/link-preserve +++ b/tests/cp/link-preserve @@ -28,8 +28,8 @@ test -f c/a || framework_failure_ test -f c/b || framework_failure_ -a_inode=`ls -i c/a|sed 's,c/.*,,'` -b_inode=`ls -i c/b|sed 's,c/.*,,'` +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') test "$a_inode" = "$b_inode" || fail=1 # -------------------------------------- @@ -38,8 +38,8 @@ touch a ln -s a b mkdir c cp --preserve=links -R -H a b c -a_inode=`ls -i c/a|sed 's,c/.*,,'` -b_inode=`ls -i c/b|sed 's,c/.*,,'` +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') test "$a_inode" = "$b_inode" || fail=1 # -------------------------------------- @@ -47,24 +47,24 @@ test "$a_inode" = "$b_inode" || fail=1 # and translates to hard-linked a and b in the destination dir. rm -rf a b c d; mkdir d; (cd d; touch a; ln -s a b) cp --preserve=links -R -L d c -a_inode=`ls -i c/a|sed 's,c/.*,,'` -b_inode=`ls -i c/b|sed 's,c/.*,,'` +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') test "$a_inode" = "$b_inode" || fail=1 # -------------------------------------- # Same as above, but starting with a/b hard linked. rm -rf a b c d; mkdir d; (cd d; touch a; ln a b) cp --preserve=links -R -L d c -a_inode=`ls -i c/a|sed 's,c/.*,,'` -b_inode=`ls -i c/b|sed 's,c/.*,,'` +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') test "$a_inode" = "$b_inode" || fail=1 # -------------------------------------- # Ensure that --no-preserve=links works. rm -rf a b c d; mkdir d; (cd d; touch a; ln a b) cp -dR --no-preserve=links d c -a_inode=`ls -i c/a|sed 's,c/.*,,'` -b_inode=`ls -i c/b|sed 's,c/.*,,'` +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') test "$a_inode" = "$b_inode" && fail=1 # -------------------------------------- @@ -73,8 +73,8 @@ rm -rf a b c d touch a; ln a b mkdir c cp -d a b c -a_inode=`ls -i c/a|sed 's,c/.*,,'` -b_inode=`ls -i c/b|sed 's,c/.*,,'` +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') test "$a_inode" = "$b_inode" || fail=1 # -------------------------------------- @@ -83,7 +83,7 @@ rm -rf a b c d touch a; chmod 731 a umask 077 cp -a --no-preserve=mode a b -mode=`ls -l b|cut -b-10` +mode=$(ls -l b|cut -b-10) test "$mode" = "-rwx------" || fail=1 umask 022 # -------------------------------------- diff --git a/tests/cp/link-symlink b/tests/cp/link-symlink index 97fbf4b9b..57bc9c715 100755 --- a/tests/cp/link-symlink +++ b/tests/cp/link-symlink @@ -25,7 +25,7 @@ touch file ln -s file link || framework_failure_ touch -m -h -d 2011-01-01 link || skip_ "Your system doesn't support updating symlink timestamps" -case `stat --format=%y link` in +case $(stat --format=%y link) in 2011-01-01*) ;; *) skip_ "Your system doesn't support updating symlink timestamps" ;; esac @@ -33,7 +33,7 @@ esac # link.cp is probably a hardlink, but may also be a symlink # In either case the timestamp should match the original. cp -al link link.cp -case `stat --format=%y link.cp` in +case $(stat --format=%y link.cp) in 2011-01-01*) ;; *) fail=1 ;; esac diff --git a/tests/cp/no-deref-link1 b/tests/cp/no-deref-link1 index 8600b8e0a..c2a565793 100755 --- a/tests/cp/no-deref-link1 +++ b/tests/cp/no-deref-link1 @@ -34,6 +34,6 @@ cp -d a/foo b 2>/dev/null # Fail this test if the exit status is not 1 test $? = 1 || fail=1 -test "`cat a/foo`" = $msg || fail=1 +test "$(cat a/foo)" = $msg || fail=1 Exit $fail diff --git a/tests/cp/no-deref-link2 b/tests/cp/no-deref-link2 index 96d444fdf..584029954 100755 --- a/tests/cp/no-deref-link2 +++ b/tests/cp/no-deref-link2 @@ -34,6 +34,6 @@ cp -d a b 2>/dev/null # Fail this test if the exit status is not 1 test $? = 1 || fail=1 -test "`cat a`" = $msg || fail=1 +test "$(cat a)" = $msg || fail=1 Exit $fail diff --git a/tests/cp/no-deref-link3 b/tests/cp/no-deref-link3 index 629f2ae8d..5f63f2699 100755 --- a/tests/cp/no-deref-link3 +++ b/tests/cp/no-deref-link3 @@ -31,6 +31,6 @@ cp -d a b 2>/dev/null # Fail this test if the exit status is not 1 test $? = 1 || fail=1 -test "`cat a`" = $msg || fail=1 +test "$(cat a)" = $msg || fail=1 Exit $fail diff --git a/tests/cp/parent-perm-race b/tests/cp/parent-perm-race index 4eb79bb47..41486fcb1 100755 --- a/tests/cp/parent-perm-race +++ b/tests/cp/parent-perm-race @@ -48,7 +48,7 @@ do echo foo ) >$attr/fifo - ls_output=`cat d/$attr.ls` || fail=1 + ls_output=$(cat d/$attr.ls) || fail=1 case $attr,$ls_output in ownership,d???--[-S]--[-S]* | \ mode,d????-??-?* | \ diff --git a/tests/cp/perm b/tests/cp/perm index 2e6126d62..eb3925da2 100755 --- a/tests/cp/perm +++ b/tests/cp/perm @@ -49,8 +49,8 @@ for u in 31 37 2; do case "$cmd:$force:$existing_dest" in cp:*:yes) - _g_perm=`echo rwx|sed 's/[^'$g_perm']/-/g'` - _o_perm=`echo rwx|sed 's/[^'$o_perm']/-/g'` + _g_perm=$(echo rwx|sed 's/[^'$g_perm']/-/g') + _o_perm=$(echo rwx|sed 's/[^'$o_perm']/-/g') expected_perms=-rw-$_g_perm$_o_perm ;; cp:*:no) diff --git a/tests/cp/preserve-gid b/tests/cp/preserve-gid index 355db4d87..6f371c3fb 100755 --- a/tests/cp/preserve-gid +++ b/tests/cp/preserve-gid @@ -39,7 +39,7 @@ t0() { g=$1; shift rm -f b || exit 1 "$@" "$f" b || exit 1 - s=`stat -c '%u %g' b` + s=$(stat -c '%u %g' b) if test "x$s" != "x$u $g"; then # Allow the actual group to match that of the parent directory # (it was set to 0 above). diff --git a/tests/cp/preserve-link b/tests/cp/preserve-link index df1d8c53f..5f069af7c 100755 --- a/tests/cp/preserve-link +++ b/tests/cp/preserve-link @@ -68,7 +68,7 @@ create_target_tree() # Note we repeat this, creating either one of # two hard linked files from source in the dest, so as to -# test both paths in `cp` for creating the hard links. +# test both paths in $(cp) for creating the hard links. # The path taken by cp is dependent on which cp encounters # first in the source, which is non deterministic currently # (I'm guessing that results are sorted by inode and diff --git a/tests/cp/r-vs-symlink b/tests/cp/r-vs-symlink index 15616ffd7..e96c58425 100755 --- a/tests/cp/r-vs-symlink +++ b/tests/cp/r-vs-symlink @@ -32,7 +32,7 @@ ln -s no-such-file no-file || framework_failure_ cp -r no-file junk 2>/dev/null || fail=1 cp -r slink bar 2>/dev/null || fail=1 -set x `ls -l bar`; shift; mode=$1 +set x $(ls -l bar); shift; mode=$1 case $mode in l*) ;; *) fail=1;; diff --git a/tests/cp/same-file b/tests/cp/same-file index d5abfe82b..dbd4d01b6 100755 --- a/tests/cp/same-file +++ b/tests/cp/same-file @@ -111,7 +111,7 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do # the destination is a copy. for f in $args; do if test -f $f; then - case "`cat $f`" in + case "$(cat $f)" in "$contents") ;; *) echo cp FAILED;; esac diff --git a/tests/cp/sparse b/tests/cp/sparse index f1633ae0e..a55202877 100755 --- a/tests/cp/sparse +++ b/tests/cp/sparse @@ -24,14 +24,14 @@ require_sparse_support_ # It has to be at least 128K in order to be sparse on some systems. # Make its size one larger than 128K, in order to tickle the # bug in coreutils-6.0. -size=`expr 128 \* 1024 + 1` +size=$(expr 128 \* 1024 + 1) dd bs=1 seek=$size of=sparse < /dev/null 2> /dev/null || framework_failure_ cp --sparse=always sparse copy || fail=1 # Ensure that the copy has the same block count as the original. -test `stat --printf %b copy` -le `stat --printf %b sparse` || fail=1 +test $(stat --printf %b copy) -le $(stat --printf %b sparse) || fail=1 # Ensure that --sparse={always,never} with --reflink fail. cp --sparse=always --reflink sparse copy && fail=1 diff --git a/tests/cp/special-bits b/tests/cp/special-bits index 40795104c..4a00891d9 100755 --- a/tests/cp/special-bits +++ b/tests/cp/special-bits @@ -33,18 +33,18 @@ chmod u=rwx,g=rx,o=rx . || framework_failure_ cp -p a a2 || fail=1 -set _ `ls -l a`; shift; p1=$1 -set _ `ls -l a2`; shift; p2=$1 +set _ $(ls -l a); shift; p1=$1 +set _ $(ls -l a2); shift; p2=$1 test $p1 = $p2 || fail=1 cp -p b b2 || fail=1 -set _ `ls -l b`; shift; p1=$1 -set _ `ls -l b2`; shift; p2=$1 +set _ $(ls -l b); shift; p1=$1 +set _ $(ls -l b2); shift; p2=$1 test $p1 = $p2 || fail=1 setuidgid $NON_ROOT_USERNAME env PATH="$PATH" cp -p c c2 || fail=1 -set _ `ls -l c`; shift; p1=$1 -set _ `ls -l c2`; shift; p2=$1 +set _ $(ls -l c); shift; p1=$1 +set _ $(ls -l c2); shift; p2=$1 test $p1 = $p2 && fail=1 Exit $fail diff --git a/tests/cp/symlink-slash b/tests/cp/symlink-slash index 0b32b9536..95c9cfa04 100755 --- a/tests/cp/symlink-slash +++ b/tests/cp/symlink-slash @@ -24,7 +24,7 @@ mkdir dir || framework_failure_ ln -s dir symlink || framework_failure_ cp -dR symlink/ s || fail=1 -set `ls -l s` +set $(ls -l s) # Prior to fileutils-4.0q, the following would have output ...'s -> dir' # because the trailing slash was removed unconditionally (now you have to -- cgit v1.2.3-54-g00ecf