8446b7
From b248789b64d6bd277c52bfe608ed3192023af1bd Mon Sep 17 00:00:00 2001
8446b7
From: "E. Choroba" <choroba@matfyz.cz>
8446b7
Date: Fri, 26 Jun 2020 21:19:24 +0200
8446b7
Subject: [PATCH] After running an action in the debugger, turn it off
8446b7
MIME-Version: 1.0
8446b7
Content-Type: text/plain; charset=UTF-8
8446b7
Content-Transfer-Encoding: 8bit
8446b7
8446b7
When running with "c", there was no problem, but when running with "n"
8446b7
or "s", once the action was executed, it kept executing on the
8446b7
following lines, which wasn't expected. Clearing $action here prevents
8446b7
this unwanted behaviour.
8446b7
8446b7
Signed-off-by: Petr Písař <ppisar@redhat.com>
8446b7
---
8446b7
 lib/perl5db.pl                   |  3 ++-
8446b7
 lib/perl5db.t                    | 22 ++++++++++++++++++++++
8446b7
 lib/perl5db/t/test-a-statement-3 |  6 ++++++
8446b7
 3 files changed, 30 insertions(+), 1 deletion(-)
8446b7
 create mode 100644 lib/perl5db/t/test-a-statement-3
8446b7
8446b7
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
8446b7
index 69a9bb6e64..e04a0e17fa 100644
8446b7
--- a/lib/perl5db.pl
8446b7
+++ b/lib/perl5db.pl
8446b7
@@ -529,7 +529,7 @@ BEGIN {
8446b7
 use vars qw($VERSION $header);
8446b7
 
8446b7
 # bump to X.XX in blead, only use X.XX_XX in maint
8446b7
-$VERSION = '1.57';
8446b7
+$VERSION = '1.58';
8446b7
 
8446b7
 $header = "perl5db.pl version $VERSION";
8446b7
 
8446b7
@@ -2708,6 +2708,7 @@ If there are any preprompt actions, execute those as well.
8446b7
         # The &-call is here to ascertain the mutability of @_.
8446b7
         &DB::eval;
8446b7
     }
8446b7
+    undef $action;
8446b7
 
8446b7
     # Are we nested another level (e.g., did we evaluate a function
8446b7
     # that had a breakpoint in it at the debugger prompt)?
8446b7
diff --git a/lib/perl5db.t b/lib/perl5db.t
8446b7
index 421229a54a..913a301d98 100644
8446b7
--- a/lib/perl5db.t
8446b7
+++ b/lib/perl5db.t
8446b7
@@ -2799,6 +2799,28 @@ SKIP:
8446b7
     );
8446b7
 }
8446b7
 
8446b7
+{
8446b7
+    # GitHub #17901
8446b7
+    my $wrapper = DebugWrap->new(
8446b7
+        {
8446b7
+            cmds =>
8446b7
+            [
8446b7
+                'a 4 $s++',
8446b7
+                ('s') x 5,
8446b7
+                'x $s',
8446b7
+                'q'
8446b7
+            ],
8446b7
+            prog => '../lib/perl5db/t/test-a-statement-3',
8446b7
+            switches => [ '-d' ],
8446b7
+            stderr => 0,
8446b7
+        }
8446b7
+    );
8446b7
+    $wrapper->contents_like(
8446b7
+        qr/^0 +2$/m,
8446b7
+        'Test that the a command runs only on the given lines.',
8446b7
+    );
8446b7
+}
8446b7
+
8446b7
 {
8446b7
     # perl 5 RT #126735 regression bug.
8446b7
     local $ENV{PERLDB_OPTS} = "NonStop=0 RemotePort=non-existent-host.tld:9001";
8446b7
diff --git a/lib/perl5db/t/test-a-statement-3 b/lib/perl5db/t/test-a-statement-3
8446b7
new file mode 100644
8446b7
index 0000000000..b188c1c5c5
8446b7
--- /dev/null
8446b7
+++ b/lib/perl5db/t/test-a-statement-3
8446b7
@@ -0,0 +1,6 @@
8446b7
+use strict; use warnings;
8446b7
+
8446b7
+for my $x (1 .. 2) {
8446b7
+    my $y = $x + 1;
8446b7
+    my $x = $x - 1;
8446b7
+}
8446b7
-- 
8446b7
2.25.4
8446b7