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

Full log


View this message in rfc822 format

From: Nora Platiel <nplatiel <at> gmx.us>
To: 45949 <at> debbugs.gnu.org
Subject: bug#45949: 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 4 years and 148 days ago.

Previous Next


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