bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45949: documentation is incorrect about the T command


From: Nora Platiel
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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]