sed-devel
[Top][All Lists]
Advanced

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

Re: understanding the T command


From: Pietro Paolini
Subject: Re: understanding the T command
Date: Fri, 15 May 2020 14:00:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

Hello,

The 'Ttb' commands will jump at the end of the script therefore no action is taken after the first match.

'in which case the next cycle is started' means that the next input line will be read from sdtin.


On 5/15/20 12:13 PM, Nora Platiel wrote:
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]