diff options
author | Shlomi Fish <shlomif@shlomifish.org> | 2014-03-27 19:07:50 +0200 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2014-05-28 13:35:25 +1000 |
commit | c59f1e04636e3bafbbd2c362defb3fe67b18d108 (patch) | |
tree | e93ecd8b84504e1dc52cea5b9ed690d3d6044ec9 /lib/perl5db.pl | |
parent | bd47baf274ecea5636da37b74e4368e6f271fed5 (diff) | |
download | perl-c59f1e04636e3bafbbd2c362defb3fe67b18d108.tar.gz |
Fix RT #121509 : perl -d handling chdir().
See: https://rt.perl.org/Ticket/Display.html?id=121509
[perl #121509] perl debugger doesn't save starting dir to restart from
Thanks to Linda Walsh for reporting the problem and RJBS for commenting
for initial approval. Fix and a regression test by Shlomi Fish.
Diffstat (limited to 'lib/perl5db.pl')
-rw-r--r-- | lib/perl5db.pl | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/perl5db.pl b/lib/perl5db.pl index 8bc015062a..e3f63b3523 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -512,12 +512,17 @@ package DB; use strict; +use Cwd (); + +my $_initial_cwd; + BEGIN {eval 'use IO::Handle'}; # Needed for flush only? breaks under miniperl BEGIN { require feature; $^V =~ /^v(\d+\.\d+)/; feature->import(":$1"); + $_initial_cwd = Cwd::getcwd(); } # Debugger for Perl 5.00x; perl5db.pl patch level: @@ -2260,6 +2265,13 @@ sub _DB__handle_restart_and_rerun_commands { # R - restart execution. # rerun - controlled restart execution. if ($cmd_cmd eq 'rerun' or $cmd_params eq '') { + + # Change directory to the initial current working directory on + # the script startup, so if the debugged program changed the + # directory, then we will still be able to find the path to the + # the program. (perl 5 RT #121509 ). + chdir ($_initial_cwd); + my @args = ($cmd_cmd eq 'R' ? restart() : rerun($cmd_params)); # Close all non-system fds for a clean restart. A more |