Changeset 10606

Show
Ignore:
Timestamp:
02/07/10 11:19:10 (7 months ago)
Author:
kthakore
Message:

Add a fix for ticket #845. The problem was that when padre is called like so 'padre somedir/file.pl'. The resulting Document object had filename = somedir/file.pl and projectdir = somdir. So when we try to run the code the command created chdir in get_command once to projectdir and then tries to run somedir/file.pl. So it crashes by try to chdir twice in somedir then run file. To fix this I made it check before chdir to see if the somedir exists. Then I also see if Document->{filename} has a \//|\/\ in it and if it does split and take the last element.

Location:
trunk/Padre/lib/Padre
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Document/Perl.pm

    r10543 r10606  
    319319        my $dir = File::Basename::dirname($filename); 
    320320        chdir $dir; 
     321         
     322        # (Ticket #845) if Padre folder/script.pl is called filename has folder/ in it so we check for that 
     323 
     324        if( $filename =~ /\\|\//) 
     325        { 
     326        my @file_name = split /\\|\//, $filename; 
     327        $filename = $file_name[$#file_name]; 
     328        } 
     329 
     330 
     331 
    321332        return $debug 
    322333                ? qq{"$perl" -Mdiagnostics(-traceonly) $run_args{interpreter} "$filename"$Script_Args} 
  • trunk/Padre/lib/Padre/Wx/Main.pm

    r10605 r10606  
    23902390                        SCOPE: { 
    23912391                                require File::pushd; 
    2392                                 my $pushd = File::pushd::pushd( $document->project_dir ); 
     2392                                # Ticket #845 this project_dir is created in correctly when you do padre somedir/script.pl and run F5 on that 
     2393                                # real stupid think so we don't crash 
     2394                                # to fix this $document->get_command needs to recognize which folder it is in 
     2395                                # The other part of this fix is in lib/Padre/Document/Perl.pm in get_command 
     2396                                # Please feel free to fix this 
     2397                                my $pushd = File::pushd::pushd( $document->project_dir) if -e $document->project_dir; 
    23932398                                $self->run_command($cmd); 
    23942399                        } 
     
    24042409                                SCOPE: { 
    24052410                                        require File::pushd; 
    2406                                         my $pushd = File::pushd::pushd( $document->project_dir ); 
     2411                                        my $pushd = File::pushd::pushd( $document->project_dir ) if -e  $document->project_dir; 
    24072412                                        $self->run_command($cmd); 
    24082413                                }