Avoid a shell bug in Tru64 4.0 sh's handling of double-quoted strings.
authorJim Meyering <jim@meyering.net>
Thu, 26 Oct 2006 09:03:30 +0000 (11:03 +0200)
committerJim Meyering <jim@meyering.net>
Thu, 26 Oct 2006 09:03:30 +0000 (11:03 +0200)
[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.

20 files changed:
ChangeLog
lib/.cvsignore
tests/chmod/c-option
tests/cp/cp-parents
tests/du/inaccessible-cwd
tests/du/long-from-unreadable
tests/install/basic-1
tests/install/trap
tests/misc/close-stdout
tests/mkdir/concurrent-1
tests/mkdir/p-1
tests/mkdir/p-3
tests/mkdir/parents
tests/mkdir/perm
tests/readlink/can-e
tests/readlink/can-f
tests/readlink/can-m
tests/rm/inaccessible
tests/rm/unread3
tests/touch/no-create-missing

index 2ee39fe..a09b538 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2006-10-25  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * 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  <jim@meyering.net>
 
        Portability to Tru64 V4.0.
index dbc2b83..ed14210 100644 (file)
@@ -321,6 +321,7 @@ tempname.c
 time_r.c
 time_r.h
 timespec.h
+uinttostr.c
 umaxtostr.c
 unicodeio.h
 unistd--.h
index 0b116c4..bf2c4a9 100755 (executable)
@@ -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
 
index c689215..373e607 100755 (executable)
@@ -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
index ea4ba7a..0f9f9b7 100755 (executable)
@@ -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
index 16f00e8..f43a6db 100755 (executable)
@@ -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
index bbb3087..9ee4525 100755 (executable)
@@ -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
index 3ebaaff..aaf0a33 100755 (executable)
@@ -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
index 01edf32..dd8bbc5 100755 (executable)
@@ -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
 
index 790e4ed..0a8c142 100755 (executable)
@@ -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
 
index 001b8b7..7e384e4 100755 (executable)
@@ -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
 
index d9e49d5..7f36717 100755 (executable)
@@ -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
 
index 46977fc..f0ead6e 100755 (executable)
@@ -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.
index 5483808..3853f2a 100755 (executable)
@@ -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
 
index d2777aa..40c8e91 100755 (executable)
@@ -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
index 51ebda8..c0cf530 100755 (executable)
@@ -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
index 78771c8..bdd4033 100755 (executable)
@@ -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
index 721210a..02128d7 100755 (executable)
@@ -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
index c8af5cf..4021a39 100755 (executable)
@@ -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
index 3f3452e..cf6b6dc 100755 (executable)
@@ -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