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: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: bin/59803: sed(1) conditional branch command confuses subsequent line addressing
Date: Sat, 29 Nov 2025 08:56:40 -0000 (UTC)
elo%sdf.org@localhost writes:
> In a sed(1) script, using the 't' command to branch when a
> substitution has been made causes a subsequent line of the script,
> qualified with an explicit address range, to be skipped for all
> remaining input if the line number of the source text in which the
> substitution was made is the same as the starting address of the
> explicit address range. Fortunately, it's much easier to demonstrate
> than it is to describe.
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.
> Minised (http://exactcode.com/opensource/minised/) demonstrates
> exactly the same perplexing behaviour as NetBSD's native sed.
Minised is a bit different in what it regards "reading of an input line"
(the didsub flag is the result of the last substitute command and
not cleared by input). But it interprets ranges the same. A line
is only considered "in range" when the start address (line number of
pattern) is matched.
Home |
Main Index |
Thread Index |
Old Index