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

Bug#408104: Broken 'diff' function in the VCS::Cvs::Version perl module (bug & fix)



Package: libvcs-cvs-perl
Version: 0.14.4
File:  /usr/share/perl5/VCS/Cvs/Version.pm

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'.

I notified the CPAN maintainer of the VCS module.
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



Reply to: