Subject: | stand alone binaries fail to resolve cwd properly |
distribution: cpan PAR::Packer-0.976
perl version: This is perl, v5.8.8 built for PA-RISC2.0
os version: HP-UX hpux-1 B.11.11 U 9000/800 1348702983 unlimited-user
license
The attached makefile demonstrates the problem. When you attempt to run
'junk' from the subdirectory, you will get errors similar to the following:
IO error: Can't open /net/filer/homes/stanton/tmp/../junk : No such file
or directory
at -e line 898
IO error: Can't open /net/filer/homes/stanton/tmp/../junk : No such file
or directory
at -e line 898
Cannot find '/net/filer/homes/stanton/tmp/../junk': No such file or
directory at /opt/perl_5.8.8/lib/site_perl/5.8.8/PAR.pm line 585.
It turns out the problem is caused by a bad PWD environment variable.
perl's chdir does not update PWD properly, so the process is invoked
with a PWD that refers to the starting directory, not 'subdir'. The
subprocess invocation works if you invoke it via sh -c, because sh
correctly updates PWD.
The attached patch file appears to resolve the problem by using Cwd,
Win32::GetCwd, or `pwd` to determine the correct value.
Subject: | par.pl.patch |
--- /home/stanton/tmp/PAR-Packer-0.976/script/par.pl 2007-07-13 09:39:25.000000000 -0700
+++ script/par.pl 2007-08-28 14:09:20.587164000 -0700
@@ -688,6 +688,7 @@
require PAR::Heavy;
require PAR::Dist;
require PAR::Filter::PodStrip;
+ eval { require Cwd };
eval { require Win32 };
eval { require Scalar::Util };
eval { require Archive::Unzip::Burst };
@@ -825,7 +826,7 @@
}
# XXX - hack to make PWD work
- my $pwd = (defined &Win32::GetCwd) ? Win32::GetCwd() : $ENV{PWD};
- $pwd = `pwd` if !defined $pwd;
+ my $pwd = (defined &Cwd::getcwd) ? Cwd::getcwd()
+ : ((defined &Win32::GetCwd) ? Win32::GetCwd() : `pwd`);
chomp($pwd);
$progname =~ s/^(?=\.\.?\Q$Config{_delim}\E)/$pwd$Config{_delim}/;
Subject: | Makefile |
Message body not shown because it is not plain text.