GNU bug report logs - #45949
documentation is incorrect about the T command

Previous Next

Package: sed;

Reported by: Nora Platiel <nplatiel <at> gmx.us>

Date: Mon, 18 Jan 2021 07:04:01 UTC

Severity: normal

To reply to this bug, email your comments to 45949 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#45949; Package sed. (Mon, 18 Jan 2021 07:04:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nora Platiel <nplatiel <at> gmx.us>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Mon, 18 Jan 2021 07:04:01 GMT) Full text and rfc822 format available.

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

From: Nora Platiel <nplatiel <at> gmx.us>
To: bug-sed <at> gnu.org
Subject: documentation is incorrect about the T command
Date: Sun, 17 Jan 2021 23:56:08 +0100
Hello,

from the docs:
> T label: (test) Branch to label only if there have been no successful
> substitutions since the last input line was read or conditional branch was
> taken. The label may be omitted, in which case the next cycle is started.

According to the above, these two commands should have the same effect, but they don't:

$ echo x | sed 's/x/X/ ; T ; aHELLO' # expected
X
HELLO

$ echo x | sed 's/x/X/ ; T ; T ; aHELLO' # unexpected
X

The second T branch is taken and the 'a' command is skipped, even though no new input line was read and no conditional branch was taken after the successful substitution.

I think the docs should be changed because the implemented behavior makes more sense and I'm already depending on it.
The documented behavior is more confusing (asymmetric: t act as a "reset point" but T doesn't), and error prone (less "reset points" means that there is a higher likelihood that older replacements come into play when they are not meant to).

I propose to change "conditional branch was taken" into "conditional branch was reached/executed" or something like that.
(Any t or T command leaves the "replaced" flag unset, regardless of whether the branch is taken or not.)

This was already discussed on sed-devel:
https://lists.gnu.org/archive/html/sed-devel/2020-05/msg00001.html
https://lists.gnu.org/archive/html/sed-devel/2020-10/msg00006.html

Thanks,
NP




This bug report was last modified 3 years and 292 days ago.

Previous Next


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