GNU bug report logs - #66411
sed --debug option prints the contents of the hold space after running the 'g' command

Previous Next

Package: sed;

Reported by: Zachary Santer <zsanter <at> gmail.com>

Date: Sun, 8 Oct 2023 19:27:03 UTC

Severity: normal

To reply to this bug, email your comments to 66411 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#66411; Package sed. (Sun, 08 Oct 2023 19:27:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Zachary Santer <zsanter <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Sun, 08 Oct 2023 19:27:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Zachary Santer <zsanter <at> gmail.com>
To: bug-sed <at> gnu.org
Subject: sed --debug option prints the contents of the hold space after
 running the 'g' command
Date: Sun, 8 Oct 2023 12:30:57 -0400
The 'g' command "[r]eplace[s] the contents of the pattern space with
the contents of the hold space." Outputting the contents of the hold
space then gives you the contents of the pattern space, but it still
doesn't make a lot of sense to do. It's not the hold space that was
updated. It's the pattern space.

$ seq 3 | sed --binary --regexp-extended --debug --expression='x; g; h'
SED PROGRAM:
  x
  g
  h
INPUT:   'STDIN' line 1
PATTERN: 1
COMMAND: x
PATTERN:
HOLD:    1
COMMAND: g
HOLD:    1
COMMAND: h
HOLD:    1
END-OF-CYCLE:
1
INPUT:   'STDIN' line 2
PATTERN: 2
COMMAND: x
PATTERN: 1
HOLD:    2
COMMAND: g
HOLD:    2
COMMAND: h
HOLD:    2
END-OF-CYCLE:
2
INPUT:   'STDIN' line 3
PATTERN: 3
COMMAND: x
PATTERN: 2
HOLD:    3
COMMAND: g
HOLD:    3
COMMAND: h
HOLD:    3
END-OF-CYCLE:
3

'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.

$ sed --version
sed (GNU sed) 4.9
[...]
$ pacman --query sed
sed 4.9-1

Being run in MSYS2 MINGW64 terminal on Windows 10.

Thanks,
Zack




Information forwarded to bug-sed <at> gnu.org:
bug#66411; Package sed. (Sat, 14 Oct 2023 12:05:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Davide Brini <dave_br <at> gmx.com>
To: bug-sed <at> gnu.org
Subject: Re: bug#66411: sed --debug option prints the contents of the hold
 space after running the 'g' command
Date: Sat, 14 Oct 2023 14:04:11 +0200
[Message part 1 (text/plain, inline)]
On Sun, 8 Oct 2023 12:30:57 -0400, Zachary Santer <zsanter <at> gmail.com> 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.
[debug_pattern.patch (text/x-patch, attachment)]

This bug report was last modified 1 year and 41 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.