--- tests/misc/pwd-long.old	2009-10-28 06:31:59.000000000 +0000
+++ tests/misc/pwd-long	2009-11-15 08:07:11.000000000 +0000
@@ -29,6 +29,31 @@
 # Don't use CuTmpdir here, since File::Temp's use of rmtree can't
 # remove the deep tree we create.
 $PERL -Tw -- - <<\EOF
+use strict;
+
+(my $ME = $ENV{ARGV_0}) =~ s|.*/||;
+# Set up a safe, well-known environment
+delete @ENV{qw(BASH_ENV CDPATH ENV)};
+$ENV{IFS}  = '';
+# PATH is tricky - we can't just clear it, or cygwin will fail.  But we
+# can't use it as-is, or taint checking in `` will stop us.  For this
+# script, it is enough to scrub the incoming $PATH first.
+$ENV{'PATH'} =~ /(.*)/;
+$ENV{'PATH'} = "$1";
+
+# Save CWD's device and inode numbers.
+my ($dev, $ino) = (stat '.')[0, 1];
+
+# Construct the expected "."-relative part of pwd's output.
+my $z = 'z' x 31;
+my $n = 256;
+my $expected = "/$z" x $n;
+# Remove the leading "/".
+substr ($expected, 0, 1) = '';
+print "end of added lines\n";
+EOF
+
+$PERL -Tw -- - <<\EOF
 
 # Show that pwd works even when the length of the resulting
 # directory name is longer than PATH_MAX.
