NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/59803: sed(1) conditional branch command confuses subsequent line addressing
The following reply was made to PR bin/59803; it has been noted by GNATS.
From: elo%sdf.org@localhost
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: bin/59803: sed(1) conditional branch command confuses subsequent
line addressing
Date: Mon, 01 Dec 2025 02:26:05 +0000
Hello, all.
Thank you very much, uwe@ and kre@, for taking the time and trouble,
as mlelstv@ did earlier, to try to help me understand why sed acts as
it does. Unfortunately, I'm no further along. I've undoubtedly made a
hash of articulating the problem, so I hope you'll forgive my having
one more, self-indulgent go.
My persistent confusion about sed's expected behaviour lies in the
implication that it keeps state (other than the contents of the
pattern and hold spaces) from one cycle to the next. Returning to my
example,
#!/usr/bin/sed -nf
=
s,a,substitution succeeded,p
t
3,$ p
when the third line of input is substituted, of course the address
range of the final 'p' command will have no effect; the entire line
is skipped by the preceding 't'. That behaviour is manifestly correct,
and is not what I meant to question. What I'm failing to grasp is
how it is that, when the fourth and subsequent lines of input are
read, and do not result in substitutions, and the branch is not taken,
the '3,$' address range is not then satisfied. How did the fact that a
substitution occurred in a previous cycle influence later cycles? The
nature of that mechanism is what continues to elude me.
Cheers,
elo
PS. My thanks also to RVP for apprehending why it is I'm finding this
so perplexing. It's much appreciated.
Home |
Main Index |
Thread Index |
Old Index