Subject: | Broken 'diff' function in the VCS::Cvs::Version perl module (bug & fix) |
Date: | Tue, 23 Jan 2007 18:14:09 +0200 |
To: | bug-vcs [...] rt.cpan.org |
From: | "Gleb Rubanau" <g.rubanau [...] gmail.com> |
OS: Debian GNU/Linux 'etch' kernel 2.6.16
Perl version: 5.8.8
Debian Package: libvcs-cvs-perl
Debian Package Version: 0.14.4
File: /usr/share/perl5/VCS/Cvs/Version.pm
Cpan module: VCS::Cvs::Version
Cpan module version: 0.6
Problem description: invoking VCS::Cvs:Version::diff subroutine (perl
code example placed below) ends in process death
Error message: "sh: chdir: command not found" during program execution
Reason: in the row 51 of the module string assumed to be executed by
shell contains perl call 'chdir' instead of a shell command 'cd'.
Patch for a Version.pm is also provided below.
vvvvvvvvvvv code example starts vvvvvvvvvvvvv
#!/usr/bin/perl
use VCS;
sub build_file_url($)
{
my $filename=shift;
$filename="$ENV{PWD}/$filename" unless $filename=~m/^\//;
$filename=~s/^\///;
my $fileurl="vcs://localhost/VCS::Cvs/$filename";
return $fileurl;
}
sub get_diff ($$$)
{
my $filename=shift;
my $version_from=shift;
my $version_to=shift;
my $fileurl=build_file_url($filename); # function building
my $fileurl1=$fileurl."/$version_from";
my $fileurl2=$fileurl."/$version_to";
my $version1=VCS::Cvs::Version->new($fileurl1);
my $version2=VCS::Cvs::Version->new($fileurl2);
my $diff=$version1->diff($version2);
return $diff;
}
$diff=get_diff('cvs.controlled.file', '2.1', '3.1');
^^^^^^^^ code example ends ^^^^^^^^^^
vvvvvvvvvvvvv patch starts vvvvvvvvvvvvvvvv
--- Version.pm.0.6.orig 2007-01-23 15:59:24.000000000 +0200
+++ Version.pm 2007-01-23 16:00:04.000000000 +0200
@@ -48,7 +48,7 @@
my $text = '';
if (ref($other) eq ref($self)) {
my $cmd =
- 'chdir ' . dirname($self->path) .
+ 'cd ' . dirname($self->path) .
" && $DIFF_CMD " .
join (' ', (map { "-r$_" } $self->version, $other->version)) .
" '" . basename($self->path) . "' |";
^^^^^^^^^ patch ends ^^^^^^^^^^^^
Best regards,
Hleb Rubanau