This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
After running an action in the debugger, turn it off
authorE. Choroba <choroba@matfyz.cz>
Fri, 26 Jun 2020 19:19:24 +0000 (21:19 +0200)
committerKarl Williamson <khw@cpan.org>
Thu, 30 Jul 2020 21:52:38 +0000 (15:52 -0600)
When running with "c", there was no problem, but when running with "n"
or "s", once the action was executed, it kept executing on the
following lines, which wasn't expected. Clearing $action here prevents
this unwanted behaviour.

lib/perl5db.pl
lib/perl5db.t
lib/perl5db/t/test-a-statement-3 [new file with mode: 0644]

index 69a9bb6..e04a0e1 100644 (file)
@@ -529,7 +529,7 @@ BEGIN {
 use vars qw($VERSION $header);
 
 # bump to X.XX in blead, only use X.XX_XX in maint
-$VERSION = '1.57';
+$VERSION = '1.58';
 
 $header = "perl5db.pl version $VERSION";
 
@@ -2708,6 +2708,7 @@ If there are any preprompt actions, execute those as well.
         # The &-call is here to ascertain the mutability of @_.
         &DB::eval;
     }
+    undef $action;
 
     # Are we nested another level (e.g., did we evaluate a function
     # that had a breakpoint in it at the debugger prompt)?
index 421229a..913a301 100644 (file)
@@ -2800,6 +2800,28 @@ SKIP:
 }
 
 {
+    # GitHub #17901
+    my $wrapper = DebugWrap->new(
+        {
+            cmds =>
+            [
+                'a 4 $s++',
+                ('s') x 5,
+                'x $s',
+                'q'
+            ],
+            prog => '../lib/perl5db/t/test-a-statement-3',
+            switches => [ '-d' ],
+            stderr => 0,
+        }
+    );
+    $wrapper->contents_like(
+        qr/^0 +2$/m,
+        'Test that the a command runs only on the given lines.',
+    );
+}
+
+{
     # perl 5 RT #126735 regression bug.
     local $ENV{PERLDB_OPTS} = "NonStop=0 RemotePort=non-existent-host.tld:9001";
     my $output = runperl( stdin => "q\n", stderr => 1, switches => [ '-d' ], prog => '../lib/perl5db/t/fact' );
diff --git a/lib/perl5db/t/test-a-statement-3 b/lib/perl5db/t/test-a-statement-3
new file mode 100644 (file)
index 0000000..b188c1c
--- /dev/null
@@ -0,0 +1,6 @@
+use strict; use warnings;
+
+for my $x (1 .. 2) {
+    my $y = $x + 1;
+    my $x = $x - 1;
+}