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