bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: groups --version


From: Eric Blake
Subject: Re: groups --version
Date: Fri, 31 Aug 2007 15:50:28 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Jim Meyering <jim <at> meyering.net> writes:

> Thanks for checking, but...
> No.  t0 is defined like this:
> 
>   t0=`echo "$0"|sed 's,.*/,,'`.tmp
> 
> so what matters is only the final component of $0.
> And since coreutils' test script basenames are all well behaved, it's safe.

Sorry for the false alarm, then.  But, on the other hand, there is a potential 
issue if the user has CDPATH set in the environment with . on the list, for 
those tests that do not source envvar-check, since $tmp is always relative.  
POSIX requires 'CDPATH=. cd $tmp' to print to stdout, whereas
'CDPATH=. cd ./$tmp' must be silent.  Also, if the user happens to have another 
directory accessible from CDPATH that matches $tmp (although this is less 
likely, due to the use of $$ in $tmp), then only the 'cd ./$tmp' form 
guarantees that CDPATH is not consulted.  So should we do this?

diff --git a/tests/sample-test b/tests/sample-test
index 4d962d0..1533c3f 100644
--- a/tests/sample-test
+++ b/tests/sample-test
@@ -33,7 +33,7 @@ trap '(exit $?); exit $?' 1 2 13 15
 
 framework_failure=0
 mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+cd ./$tmp || framework_failure=1
 
 if test $framework_failure = 1; then
   echo "$0: failure in testing framework" 1>&2


or possibly this?

diff --git a/tests/sample-test b/tests/sample-test
index 4d962d0..bc42592 100644
--- a/tests/sample-test
+++ b/tests/sample-test
@@ -27,7 +27,7 @@ fi
 # FIXME: PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
 
 pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
+t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=./$t0/$$
 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status'
 0
 trap '(exit $?); exit $?' 1 2 13 15


-- 
Eric Blake






reply via email to

[Prev in Thread] Current Thread [Next in Thread]