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: Sun, 30 Nov 2025 06:42:38 GMT
Hello, Michael.
> I can confirm that behaviour.
>
> The issue is that the address range '3,$' doesn't match linenumbers
> between 3 and end-of-file. Instead the match starts when seeing line 3
> and ends when seeing end-of-file.
>
> Since line 3 is skipped by the 't' command, the address range never
> matches.
>
> No idea if that is right or wrong, but it behaves exactly like an
> address match that uses a regular expression instead of a line number.
> If the matching line for the start condition is skipped, the range
> will never apply.
Thank you for replying to my PR so promptly. I have the uncomfortable
feeling I'm being a bit thick here. I don't know when an address
range is pre-compiled/compiled/interpreted (delete as appropriate) by
sed--whether before any input is read, or the first time the script
line qualified by the address range is encountered whilst reading
input, or every time the script line is encountered (I really should
take the trouble to look at the sed source at some point)--but in none
of those scenarios is it yet clear to me in the abstract why or how
the address range should be rendered ineffectual when the text in the
pattern space in a given cycle has not been substituted, and the 't'
command consequently has not altered the program flow.
The sed man page is seemingly unequivocal, at least in this passage:
Normally, sed cyclically copies a line of input, not including
its terminating newline character, into a pattern space, [...],
applies all of the commands with addresses that select that
pattern space, copies the pattern space to the standard output,
appending a newline, and deletes the pattern space.
Perhaps 'Normally' is bearing a heavier load than I at first realised.
In any case, if you're content that sed's behaviour is satisfactory as
it stands, that's all I need for now. If you haven't done already, I'm
happy for you to close this PR. Thanks again for taking the trouble to
explain things to me.
Cheers,
elo
Home |
Main Index |
Thread Index |
Old Index