diff options
author | Jim Meyering <meyering@redhat.com> | 2012-04-03 20:32:44 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-04-04 12:20:56 +0200 |
commit | e43d30eab3215bc9ff49ec7db3d3e2baa95ba070 (patch) | |
tree | b3828ca5bdc794f9b8648af1996d2863663c8590 /tests/chown | |
parent | 64ecea53d9b4c1ecbf6d02ff8c4ae98b3a82e9a2 (diff) | |
download | coreutils-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/chown')
-rwxr-xr-x | tests/chown/basic | 12 | ||||
-rwxr-xr-x | tests/chown/deref | 2 | ||||
-rwxr-xr-x | tests/chown/preserve-root | 8 | ||||
-rwxr-xr-x | tests/chown/separator | 8 |
4 files changed, 15 insertions, 15 deletions
diff --git a/tests/chown/basic b/tests/chown/basic index 98145dac1..7c8951c83 100755 --- a/tests/chown/basic +++ b/tests/chown/basic @@ -25,12 +25,12 @@ touch f || framework_failure_ chown -R --preserve-root 0:1 f # Make sure the owner and group are 0 and 1 respectively. -set _ `ls -n f`; shift; test "$3:$4" = 0:1 || fail=1 +set _ $(ls -n f); shift; test "$3:$4" = 0:1 || fail=1 # Make sure the correct diagnostic is output # Note we output a name even though an id was specified. chown -v --from=42 43 f > out || fail=1 -printf "ownership of 'f' retained as `id -nu`\n" > exp +printf "ownership of 'f' retained as $(id -nu)\n" > exp compare exp out || fail=1 # Ensure diagnostics work for non existent files. @@ -41,19 +41,19 @@ compare exp out || fail=1 chown --from=0:1 2:010 f || fail=1 # And now they should be 2 and 10 respectively. -set _ `ls -n f`; shift; test "$3:$4" = 2:10 || fail=1 +set _ $(ls -n f); shift; test "$3:$4" = 2:10 || fail=1 ln -s f slink # Applying chown to a symlink with --no-dereference # should change only the link. chown --no-dereference 0:1 slink || fail=1 # owner/group on the symlink should be set -set _ `ls -n slink`; shift; test "$3:$4" = 0:1 || fail=1 +set _ $(ls -n slink); shift; test "$3:$4" = 0:1 || fail=1 # owner/group on the referent should remain unchanged -set _ `ls -n f`; shift; test "$3:$4" = 2:10 || fail=1 +set _ $(ls -n f); shift; test "$3:$4" = 2:10 || fail=1 chown --no-dereference --from=0:1 2:010 slink || fail=1 # owner/group on the symlink should be changed -set _ `ls -n slink`; shift; test "$3:$4" = 2:10 || fail=1 +set _ $(ls -n slink); shift; test "$3:$4" = 2:10 || fail=1 Exit $fail diff --git a/tests/chown/deref b/tests/chown/deref index 9ba28062e..d42a05412 100755 --- a/tests/chown/deref +++ b/tests/chown/deref @@ -23,7 +23,7 @@ print_ver_ chown ln -s no-such dangle || framework_failure_ -set _ `ls -ldo dangle`; shift; user=$3 +set _ $(ls -ldo dangle); shift; user=$3 # With 5.2.1 and earlier, this command would mistakenly succeed. chown --dereference $user dangle 2> out1 && fail=1 diff --git a/tests/chown/preserve-root b/tests/chown/preserve-root index a9145b7ab..ffad22228 100755 --- a/tests/chown/preserve-root +++ b/tests/chown/preserve-root @@ -38,13 +38,13 @@ chmod -R --preserve-root u+r / >> out 2>&1 && fail=1 # since the symlink in question is not a command line argument. # Contrary to the above commands, these two should succeed. echo '==== test -RHh' >> out -chown -RHh --preserve-root `id -u` d >> out 2>&1 || fail=1 -chgrp -RHh --preserve-root `id -g` d >> out 2>&1 || fail=1 +chown -RHh --preserve-root $(id -u) d >> out 2>&1 || fail=1 +chgrp -RHh --preserve-root $(id -g) d >> out 2>&1 || fail=1 # These must fail. echo '==== test -RLh' >> out -chown -RLh --preserve-root `id -u` d >> out 2>&1 && fail=1 -chgrp -RLh --preserve-root `id -g` d >> out 2>&1 && fail=1 +chown -RLh --preserve-root $(id -u) d >> out 2>&1 && fail=1 +chgrp -RLh --preserve-root $(id -g) d >> out 2>&1 && fail=1 cat <<\EOF > exp || fail=1 chown: it is dangerous to operate recursively on '/' diff --git a/tests/chown/separator b/tests/chown/separator index 6295fd78f..d4264a8c8 100755 --- a/tests/chown/separator +++ b/tests/chown/separator @@ -19,16 +19,16 @@ . "${srcdir=.}/init.sh"; path_prepend_ ../src print_ver_ chown -id_u=`id -u` || framework_failure_ +id_u=$(id -u) || framework_failure_ test -n "$id_u" || framework_failure_ -id_un=`id -un` || framework_failure_ +id_un=$(id -un) || framework_failure_ test -n "$id_un" || framework_failure_ -id_g=`id -g` || framework_failure_ +id_g=$(id -g) || framework_failure_ test -n "$id_g" || framework_failure_ -id_gn=`id -gn` || framework_failure_ +id_gn=$(id -gn) || framework_failure_ test -n "$id_gn" || framework_failure_ # FreeBSD 6.x's getgrnam fails to look up a group name containing |