Subject: bug#66411: sed --debug option prints the contents of the hold space after running the 'g' command

From: Davide Brini <[email-masked]>
Date: Sat, 14 Oct 2023 14:04:11 +0200

On Sun, 8 Oct 2023 12:30:57 -0400, Zachary Santer <[email-masked]> wrote:

> 'x' updates both pattern and hold spaces, and you get the contents of
> both in the debugging output. 'h' updates the hold space, and you get
> the contents of the hold space in the debugging output. 'g' updates
> the pattern space, and you get the contents of the hold space in the
> debugging output.

While personally for clearness I'd just always print both pattern and hold
space after every command, I think the attached patch would do what you want
(which seems more logical to me too).

--
D.
diff --git a/sed/execute.c b/sed/execute.c
index 5f82e87..9a43a95 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -1416,7 +1416,7 @@ execute_program (struct vector *vec, struct input *input)
                  We keep it true because it's what sed <= 4.1.5 did.  */
               line_copy (&hold, &line, true);
               if (debug)
-                debug_print_line (&hold);
+                debug_print_line (&line);
               break;

             case 'G':