[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#32494: t incorrectly branching
From: |
Davide Brini |
Subject: |
bug#32494: t incorrectly branching |
Date: |
Tue, 21 Aug 2018 18:09:58 +0200 |
On Tue, 21 Aug 2018 12:36:25 +0200, Ruben Maes <address@hidden> wrote:
> printf 'Hello\n' | sed '
> s/foobar//
> t end
> s/Hello/Goodbye/
> :end'
>
> This works as expected, it prints Goodbye.
>
>
> printf 'Hello\n' | sed '
> s/Hello/Hello to you/
> s/foobar//
> t end
> s/Hello/Goodbye/
> :end'
>
> Since t should only look at whether the *last* substitution changed the
> pattern space, it is my understanding that this should print: Goodbye to
> you But sed prints instead:
> Hello to you
>
> If I got this right, that means there's a bug in sed – maybe resetting
> the "last substitution was successful" flag isn't done properly? Or am I
> misunderstanding something here after all?
Here's what the man says:
"If a s/// has done a successful substitution since the last input line was
read and since the last t or T command, then branch to label"
The standard says:
"Branch to the : command verb bearing the label if any substitutions have
been made since the most recent reading of an input line or execution of a
t. If label is not specified, branch to the end of the script."
So it looks to me like sed is producing the expected behavior.
--
D.