From b40b5b6917f62f59eff8f8bd913bd79e4cebe8f2 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 26 Oct 2006 11:03:30 +0200 Subject: [PATCH] Avoid a shell bug in Tru64 4.0 sh's handling of double-quoted strings. [patch by Paul Eggert] * tests/chmod/c-option: When double-quoting part of a word, prefer to double-quote the whole word. This is a bit easier to read (at least for me), and in some cases it avoids a shell bug with Tru64 4.0 sh reported by Nelson H. F. Beebe. For example, instead of "$abs_srcdir"/../setgid-check we now write "$abs_srcdir/../setgid-check". * tests/cp/cp-parents: Likewise. * tests/du/inaccessible-cwd: Likewise. * tests/du/long-from-unreadable: Likewise. * tests/install/basic-1: Likewise. * tests/install/trap: Likewise. * tests/misc/close-stdout: Likewise. * tests/mkdir/concurrent-1: Likewise. * tests/mkdir/p-1: Likewise. * tests/mkdir/p-3: Likewise. * tests/mkdir/parents: Likewise. * tests/mkdir/perm: Likewise. * tests/readlink/can-e: Likewise. * tests/readlink/can-f: Likewise. * tests/readlink/can-m: Likewise. * tests/rm/inaccessible: Likewise. * tests/rm/unread3: Likewise. * tests/touch/no-create-missing: Likewise. * lib/.cvsignore: Add uinttostr.c. --- ChangeLog | 28 ++++++++++++++++++++++++++++ lib/.cvsignore | 1 + tests/chmod/c-option | 2 +- tests/cp/cp-parents | 2 +- tests/du/inaccessible-cwd | 2 +- tests/du/long-from-unreadable | 2 +- tests/install/basic-1 | 4 ++-- tests/install/trap | 4 ++-- tests/misc/close-stdout | 12 ++++++------ tests/mkdir/concurrent-1 | 2 +- tests/mkdir/p-1 | 2 +- tests/mkdir/p-3 | 14 +++++++------- tests/mkdir/parents | 6 +++--- tests/mkdir/perm | 4 ++-- tests/readlink/can-e | 2 +- tests/readlink/can-f | 2 +- tests/readlink/can-m | 2 +- tests/rm/inaccessible | 6 +++--- tests/rm/unread3 | 12 ++++++------ tests/touch/no-create-missing | 4 ++-- 20 files changed, 71 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ee39fe..a09b538 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2006-10-25 Paul Eggert + + * tests/chmod/c-option: When double-quoting part of a word, prefer + to double-quote the whole word. This is a bit easier to read (at + least for me), and in some cases it avoids a shell bug with Tru64 + 4.0 sh reported by Nelson H. F. Beebe. For example, instead of + "$abs_srcdir"/../setgid-check we now write + "$abs_srcdir/../setgid-check". + * tests/cp/cp-parents: Likewise. + * tests/du/inaccessible-cwd: Likewise. + * tests/du/long-from-unreadable: Likewise. + * tests/install/basic-1: Likewise. + * tests/install/trap: Likewise. + * tests/misc/close-stdout: Likewise. + * tests/mkdir/concurrent-1: Likewise. + * tests/mkdir/p-1: Likewise. + * tests/mkdir/p-3: Likewise. + * tests/mkdir/parents: Likewise. + * tests/mkdir/perm: Likewise. + * tests/readlink/can-e: Likewise. + * tests/readlink/can-f: Likewise. + * tests/readlink/can-m: Likewise. + * tests/rm/inaccessible: Likewise. + * tests/rm/unread3: Likewise. + * tests/touch/no-create-missing: Likewise. + + * lib/.cvsignore: Add uinttostr.c. + 2006-10-25 Jim Meyering Portability to Tru64 V4.0. diff --git a/lib/.cvsignore b/lib/.cvsignore index dbc2b83..ed14210 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -321,6 +321,7 @@ tempname.c time_r.c time_r.h timespec.h +uinttostr.c umaxtostr.c unicodeio.h unistd--.h diff --git a/tests/chmod/c-option b/tests/chmod/c-option index 0b116c4..bf2c4a9 100755 --- a/tests/chmod/c-option +++ b/tests/chmod/c-option @@ -50,7 +50,7 @@ if test $framework_failure = 1; then (exit 1); exit 1 fi -. "$abs_srcdir"/../setgid-check +. "$abs_srcdir/../setgid-check" fail=0 diff --git a/tests/cp/cp-parents b/tests/cp/cp-parents index c689215..373e607 100755 --- a/tests/cp/cp-parents +++ b/tests/cp/cp-parents @@ -44,7 +44,7 @@ cd "$pwd" || framework_failure=1 mkdir -p $tmp || framework_failure=1 cd $tmp || framework_failure=1 -. "$abs_srcdir"/../setgid-check +. "$abs_srcdir/../setgid-check" mkdir foo bar || framework_failure=1 mkdir -p a/b/c d e || framework_failure=1 diff --git a/tests/du/inaccessible-cwd b/tests/du/inaccessible-cwd index ea4ba7a..0f9f9b7 100755 --- a/tests/du/inaccessible-cwd +++ b/tests/du/inaccessible-cwd @@ -48,6 +48,6 @@ fi fail=0 -du "$pwd"/$tmp/a > /dev/null || fail=1 +du "$pwd/$tmp/a" > /dev/null || fail=1 (exit $fail); exit $fail diff --git a/tests/du/long-from-unreadable b/tests/du/long-from-unreadable index 16f00e8..f43a6db 100755 --- a/tests/du/long-from-unreadable +++ b/tests/du/long-from-unreadable @@ -84,6 +84,6 @@ if test $framework_failure = 1; then fi fail=0 -du -s "$pwd"/$tmp/$dir > /dev/null || fail=1 +du -s "$pwd/$tmp/$dir" > /dev/null || fail=1 (exit $fail); exit $fail diff --git a/tests/install/basic-1 b/tests/install/basic-1 index bbb3087..9ee4525 100755 --- a/tests/install/basic-1 +++ b/tests/install/basic-1 @@ -117,7 +117,7 @@ test -d newdir3 || fail=1 # hence cannot do anything meaningful with the following relative-named dirs. abs=$pwd/$tmp mkdir sub || fail=1 -(cd sub && chmod 0 . && ginstall -d "$abs"/xx/yy rel/sub1 rel/sub2 2> /dev/null) && fail=1 +(cd sub && chmod 0 . && ginstall -d "$abs/xx/yy" rel/sub1 rel/sub2 2> /dev/null) && fail=1 chmod 755 sub # Ensure that the first argument-dir has been created. @@ -132,7 +132,7 @@ test -d xx/rel && fail=1 # inaccessible parent. coreutils 5.97 fails this test. mkdir -p sub1/d || fail=1 (cd sub1/d && chmod a-rx .. && chmod a-r . && - ginstall -d "$abs"/xx/zz rel/a rel/b 2> /dev/null) || fail=1 + ginstall -d "$abs/xx/zz" rel/a rel/b 2> /dev/null) || fail=1 chmod 755 sub1 sub1/d || fail=1 test -d xx/zz || fail=1 test -d sub1/d/rel/a || fail=1 diff --git a/tests/install/trap b/tests/install/trap index 3ebaaff..aaf0a33 100755 --- a/tests/install/trap +++ b/tests/install/trap @@ -43,10 +43,10 @@ fail=0 # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. ( # ash doesn't support "trap '' CHLD"; it knows only signal numbers. - sig=`"$pwd"/../../src/kill -l CHLD 2>/dev/null` && trap '' $sig + sig=`"$pwd/../../src/kill" -l CHLD 2>/dev/null` && trap '' $sig # Before 2004-04-21, install would infloop, in the `while (wait...' loop: - exec ginstall -s "$pwd"/../../src/ginstall$EXEEXT . + exec ginstall -s "$pwd/../../src/ginstall$EXEEXT" . ) (exit $fail); exit $fail diff --git a/tests/misc/close-stdout b/tests/misc/close-stdout index 01edf32..dd8bbc5 100755 --- a/tests/misc/close-stdout +++ b/tests/misc/close-stdout @@ -56,21 +56,21 @@ mv d e >&- || fail=1 rmdir e >&- || fail=1 touch e >&- || fail=1 sleep 0 >&- || fail=1 -"$pwd"/../../src/true >&- || fail=1 -"$pwd"/../../src/printf '' >&- || fail=1 +"$pwd/../../src/true" >&- || fail=1 +"$pwd/../../src/printf" '' >&- || fail=1 # If >&- works, ensure these fail, because stdout is closed and they # *do* generate output. >&- apparently does not work in HP-UX 11.23. # This test is ineffective unless /dev/stdout also works. -if "$pwd"/../../src/test -w /dev/stdout >/dev/null && - "$pwd"/../../src/test ! -w /dev/stdout >&-; then - "$pwd"/../../src/printf 'foo' >&- 2>/dev/null && fail=1 +if "$pwd/../../src/test" -w /dev/stdout >/dev/null && + "$pwd/../../src/test" ! -w /dev/stdout >&-; then + "$pwd/../../src/printf" 'foo' >&- 2>/dev/null && fail=1 cp --verbose a b >&- 2>/dev/null && fail=1 fi # Likewise for /dev/full, if /dev/full works. if test -w /dev/full && test -c /dev/full; then - "$pwd"/../../src/printf 'foo' >/dev/full 2>/dev/null && fail=1 + "$pwd/../../src/printf" 'foo' >/dev/full 2>/dev/null && fail=1 cp --verbose a b >/dev/full 2>/dev/null && fail=1 fi diff --git a/tests/mkdir/concurrent-1 b/tests/mkdir/concurrent-1 index 790e4ed..0a8c142 100755 --- a/tests/mkdir/concurrent-1 +++ b/tests/mkdir/concurrent-1 @@ -32,7 +32,7 @@ tmp=`echo "$0"|sed 's,.*/,,'`.tmp trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 trap '(exit $?); exit' 1 2 13 15 -mkdir --parents "$pwd"/$tmp/a/b/c || fail=1 +mkdir --parents "$pwd/$tmp/a/b/c" || fail=1 test -d $tmp || fail=1 diff --git a/tests/mkdir/p-1 b/tests/mkdir/p-1 index 001b8b7..7e384e4 100755 --- a/tests/mkdir/p-1 +++ b/tests/mkdir/p-1 @@ -28,7 +28,7 @@ tmp=`echo "$0"|sed 's,.*/,,'`.tmp trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 trap '(exit $?); exit' 1 2 13 15 -mkdir --parents "$pwd"/$tmp || fail=1 +mkdir --parents "$pwd/$tmp" || fail=1 test -d $tmp || fail=1 diff --git a/tests/mkdir/p-3 b/tests/mkdir/p-3 index d9e49d5..7f36717 100755 --- a/tests/mkdir/p-3 +++ b/tests/mkdir/p-3 @@ -45,20 +45,20 @@ if test $framework_failure = 1; then fi p=$pwd/$tmp -(cd no-access && chmod 0 . && mkdir -p "$p"/a/b u/v) 2> /dev/null && fail=1 -test -d "$p"/a/b || fail=1 +(cd no-access && chmod 0 . && mkdir -p "$p/a/b" u/v) 2> /dev/null && fail=1 +test -d "$p/a/b" || fail=1 # Same as above, but with a following *absolute* name, it should succeed -(cd no-acce2s && chmod 0 . && mkdir -p "$p"/b/b "$p"/z) || fail=1 -test -d "$p"/b/b && test -d "$p"/z || fail=1 +(cd no-acce2s && chmod 0 . && mkdir -p "$p/b/b" "$p/z") || fail=1 +test -d "$p/b/b" && test -d "$p/z" || fail=1 # Same as above, but a trailing relative name in an unreadable directory # whose parent is inaccessible. coreutils 5.97 fails this test. -(cd no-acce3s/d && chmod a-rx .. && chmod a-r . && mkdir -p a/b "$p"/b/c d/e && +(cd no-acce3s/d && chmod a-rx .. && chmod a-r . && mkdir -p a/b "$p/b/c" d/e && test -d a/b && test -d d/e) || fail=1 -test -d "$p"/b/c || fail=1 +test -d "$p/b/c" || fail=1 -b=`ls "$p"/a|tr -d '\n'` +b=`ls "$p/a" | tr -d '\n'` # With coreutils-5.3.0, this would fail with $b=bu. test "x$b" = xb || fail=1 diff --git a/tests/mkdir/parents b/tests/mkdir/parents index 46977fc..f0ead6e 100755 --- a/tests/mkdir/parents +++ b/tests/mkdir/parents @@ -44,7 +44,7 @@ if test $framework_failure = 1; then (exit 1); exit 1 fi -. "$abs_srcdir"/../setgid-check +. "$abs_srcdir/../setgid-check" fail=0 @@ -56,12 +56,12 @@ mkdir e-dir > /dev/null 2>&1 && fail=1 # Create an existing directory. umask 077 mode_str=drwxr-x-wx -mode_arg=`"$abs_srcdir"/../rwx-to-mode $mode_str` +mode_arg=`"$abs_srcdir/../rwx-to-mode" $mode_str` mkdir -m $mode_arg a || fail=1 # this `mkdir -p ...' shouldn't change perms of existing dir `a'. d_mode_str=drwx-w--wx -d_mode_arg=`"$abs_srcdir"/../rwx-to-mode $d_mode_str` +d_mode_arg=`"$abs_srcdir/../rwx-to-mode" $d_mode_str` mkdir -p -m $d_mode_arg a/b/c/d # Make sure the permissions of `a' haven't been changed. diff --git a/tests/mkdir/perm b/tests/mkdir/perm index 5483808..3853f2a 100755 --- a/tests/mkdir/perm +++ b/tests/mkdir/perm @@ -45,8 +45,8 @@ if test $framework_failure = 1; then (exit 1); exit 1 fi -. "$abs_srcdir"/../setgid-check -. "$abs_srcdir"/../umask-check +. "$abs_srcdir/../setgid-check" +. "$abs_srcdir/../umask-check" fail=0 diff --git a/tests/readlink/can-e b/tests/readlink/can-e index d2777aa..40c8e91 100755 --- a/tests/readlink/can-e +++ b/tests/readlink/can-e @@ -31,7 +31,7 @@ trap 'status=$?; (exit $status); exit $status' 1 2 13 15 fail=1 while :; do bindir=`cd ../../src && pwd`|| break - my_pwd=`"$bindir"/pwd` || break + my_pwd=`"$bindir/pwd"` || break mkdir -p $tmp || break cd $tmp || break diff --git a/tests/readlink/can-f b/tests/readlink/can-f index 51ebda8..c0cf530 100755 --- a/tests/readlink/can-f +++ b/tests/readlink/can-f @@ -31,7 +31,7 @@ trap 'status=$?; (exit $status); exit $status' 1 2 13 15 fail=1 while :; do bindir=`cd ../../src && pwd`|| break - my_pwd=`"$bindir"/pwd` || break + my_pwd=`"$bindir/pwd"` || break mkdir -p $tmp || break cd $tmp || break diff --git a/tests/readlink/can-m b/tests/readlink/can-m index 78771c8..bdd4033 100755 --- a/tests/readlink/can-m +++ b/tests/readlink/can-m @@ -31,7 +31,7 @@ trap 'status=$?; (exit $status); exit $status' 1 2 13 15 fail=1 while :; do bindir=`cd ../../src && pwd`|| break - my_pwd=`"$bindir"/pwd` || break + my_pwd=`"$bindir/pwd"` || break mkdir -p $tmp || break cd $tmp || break diff --git a/tests/rm/inaccessible b/tests/rm/inaccessible index 721210a..02128d7 100755 --- a/tests/rm/inaccessible +++ b/tests/rm/inaccessible @@ -56,9 +56,9 @@ fail=0 p=$pwd/$tmp set +x -(cd no-access; chmod 0 . && rm -r "$p"/abs1 rel "$p"/abs2) 2> out && fail=1 -test -d "$p"/abs1 && fail=1 -test -d "$p"/abs2 && fail=1 +(cd no-access; chmod 0 . && rm -r "$p/abs1" rel "$p/abs2") 2> out && fail=1 +test -d "$p/abs1" && fail=1 +test -d "$p/abs2" && fail=1 cat <<\EOF > exp || fail=1 rm: cannot remove `rel': Permission denied diff --git a/tests/rm/unread3 b/tests/rm/unread3 index c8af5cf..4021a39 100755 --- a/tests/rm/unread3 +++ b/tests/rm/unread3 @@ -47,16 +47,16 @@ chmod u=x,go= . t=$pwd/$tmp # With coreutils-5.2.1, this would get a failed assertion. -rm -r "$t"/a "$t"/b || fail=1 +rm -r "$t/a" "$t/b" || fail=1 # With coreutils-5.2.1, this would get the following: # rm: cannot get current directory: Permission denied # rm: failed to return to initial working directory: Bad file descriptor -rm -r "$t"/d "$t"/e || fail=1 +rm -r "$t/d" "$t/e" || fail=1 -test -d "$t"/a && fail=1 -test -d "$t"/b && fail=1 -test -d "$t"/d && fail=1 -test -d "$t"/e && fail=1 +test -d "$t/a" && fail=1 +test -d "$t/b" && fail=1 +test -d "$t/d" && fail=1 +test -d "$t/e" && fail=1 (exit $fail); exit $fail diff --git a/tests/touch/no-create-missing b/tests/touch/no-create-missing index 3f3452e..cf6b6dc 100755 --- a/tests/touch/no-create-missing +++ b/tests/touch/no-create-missing @@ -46,8 +46,8 @@ touch -ca no-file > /dev/null 2>&1 || fail=1 # If >&- works, test "touch -c -" etc. # >&- apparently does not work in HP-UX 11.23. # This test is ineffective unless /dev/stdout also works. -if "$pwd"/../../src/test -w /dev/stdout >/dev/null && - "$pwd"/../../src/test ! -w /dev/stdout >&-; then +if "$pwd/../../src/test" -w /dev/stdout >/dev/null && + "$pwd/../../src/test" ! -w /dev/stdout >&-; then touch -c - >&- 2> /dev/null || fail=1 touch -cm - >&- 2> /dev/null || fail=1 touch -ca - >&- 2> /dev/null || fail=1 -- 2.7.4