sed-devel
[Top][All Lists]
Advanced

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

understanding the T command


From: Nora Platiel
Subject: understanding the T command
Date: Fri, 15 May 2020 13:13:39 +0200

Hello,
I'm confused about conditional branching, especially the T command. Consider 
this script:

s/x/X/; #1
T     ; #2
s/y/Y/; #3
T     ; #4
s/^/Z/; #5

Input line "x" produces output line "X", why not "ZX"?

This is what I would expect to happen for line "x":
- replacement #1 is successful
- conditional branch #2 is not taken
- replacement #3 is not successful
- conditional branch #4 is not taken
- replacement #5 is successful

Conditional branch #4 should not be taken because replacement #1 succeeded, and 
no line is read nor conditional branch taken between #1 and #4.
I hope someone here can clarify.
Thanks.

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




reply via email to

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