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
This commit is contained in:
Jim Meyering
2012-04-03 20:32:44 +02:00
parent 64ecea53d9
commit e43d30eab3
124 changed files with 429 additions and 429 deletions

View File

@@ -30,7 +30,7 @@ ln -s -L -P symlink2 symlink3 || fail=1
# ===================================================
# ensure that -L follows symlinks, and overrides -P
ln -P -L symlink3 hard-to-a || fail=1
ls=`ls -lG hard-to-a`x
ls=$(ls -lG hard-to-a)x
case "$ls" in
*'hard-to-ax') ;;
*'hard-to-a -> '*x) fail=1 ;;
@@ -40,7 +40,7 @@ esac
# ===================================================
# ensure that -P links (or at least duplicates) symlinks, and overrides -L
ln -L -P symlink3 hard-to-3 || fail=1
ls=`ls -lG hard-to-3`x
ls=$(ls -lG hard-to-3)x
case "$ls" in
*'hard-to-3 -> symlink2x') ;;
*'hard-to-3x') fail=1 ;;
@@ -52,7 +52,7 @@ esac
# Create a hard link to a dangling symlink.
ln -s /no-such-dir || framework_failure_
ln -L no-such-dir hard-to-dangle 2>err && fail=1
case `cat err` in
case $(cat err) in
*" accessing 'no-such-dir'":*) ;;
*) fail=1 ;;
esac
@@ -63,12 +63,12 @@ ln -P no-such-dir hard-to-dangle || fail=1
mkdir d || framework_failure_
ln -s d link-to-dir || framework_failure_
ln -L link-to-dir hard-to-dir-link 2>err && fail=1
case `cat err` in
case $(cat err) in
*": 'link-to-dir': hard link not allowed for directory"*) ;;
*) fail=1 ;;
esac
ln -P link-to-dir/ hard-to-dir-link 2>err && fail=1
case `cat err` in
case $(cat err) in
*": 'link-to-dir/': hard link not allowed for directory"*) ;;
*) fail=1 ;;
esac

View File

@@ -91,7 +91,7 @@ rm -rf $d $f $ld || framework_failure_
touch $f || framework_failure_
mkdir $d || framework_failure_
ln -s $d $ld
af=`pwd`/$f
af=$(pwd)/$f
ln --no-dereference -fs "$af" $ld || fail=1
test -f $ld || fail=1
rm -rf $d $f $ld

View File

@@ -23,7 +23,7 @@ echo foo > a || framework_failure_
ln -s . b || framework_failure_
ln -sf a b > err 2>&1 && fail=1
case `cat err` in
case $(cat err) in
*'are the same file') ;;
*) fail=1 ;;
esac