]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
* tests/misc/pwd-long: Undo last change, since it made Perl invoke
authorJim Meyering <jim@meyering.net>
Mon, 23 Oct 2006 09:52:48 +0000 (11:52 +0200)
committerJim Meyering <jim@meyering.net>
Mon, 23 Oct 2006 09:52:48 +0000 (11:52 +0200)
pwd via a shell.  Instead, ensure that the absolute name of the
pwd binary consists solely of reasonable characters.

ChangeLog
tests/misc/pwd-long

index 397a3218e9f439ff2dd40659ac7293a465e730d2..3f5b181dcfc640a9565e6bca3c5cd242395f3aec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2006-10-23  Jim Meyering  <jim@meyering.net>
 
+       * tests/misc/pwd-long: Undo last change, since it made Perl invoke
+       pwd via a shell.  Instead, ensure that the absolute name of the
+       pwd binary consists solely of reasonable characters.
+
        * NEWS: Add a line for 6.5-cvs.
        * configure.ac (AC_INIT): Bump to 6.5 and add "-cvs" suffix.
 
index bf6d00441602f0670a1932e942e63a2b0e9941c0..a9fb4022ea504c5c0bf1c3547e1de738e01c5c90 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Check "printf" with long arguments.
+# Ensure that pwd works even when run from a very deep directory.
 
 # Copyright (C) 2006 Free Software Foundation, Inc.
 
@@ -46,7 +46,7 @@ export ARGV_0
 CWD=$pwd/$tmp
 export CWD
 
-$PERL -w -- - <<\EOF
+exec $PERL -Tw -- - <<\EOF
 
 # Show that pwd works even when the length of the resulting
 # directory name is longer than PATH_MAX.
@@ -55,6 +55,10 @@ use Cwd;
 
 (my $ME = $ENV{ARGV_0}) =~ s|.*/||;
 
+# Set up a safe, well-known environment
+delete @ENV{qw(BASH_ENV CDPATH ENV PATH)};
+$ENV{IFS}  = '';
+
 my $cwd = $ENV{CWD};
 my $z = 'z' x 31;
 my $n = 256;
@@ -72,10 +76,19 @@ until (++$i == $n);
 my $build_src_dir = $ENV{BUILD_SRC_DIR};
 $build_src_dir
   or die "$ME: envvar BUILD_SRC_DIR not defined\n";
+if ($build_src_dir !~ m!^([-.:/\w]+)$!)
+  {
+    warn "$0: skipping this test; odd build source directory name:\n"
+      . "$build_src_dir\n";
+    exit 77;
+  }
+$build_src_dir = $1;
+
 my $pwd_binary = "$build_src_dir/pwd";
+
 -x $pwd_binary
   or die "$ME: $pwd_binary is not an executable file\n";
-chomp (my $actual = `"$pwd_binary"`);
+chomp (my $actual = `$pwd_binary`);
 if ($expected ne $actual)
   {
     my $e_len = length $expected;