GNU bug report logs -
#32494
t incorrectly branching
Previous Next
Reported by: Ruben Maes <ruben <at> janmaes.com>
Date: Tue, 21 Aug 2018 15:23:01 UTC
Severity: normal
Tags: notabug
Done: Eric Blake <eblake <at> redhat.com>
Bug is archived. No further changes may be made.
Full log
Message #21 received at 32494 <at> debbugs.gnu.org (full text, mbox):
On Tue, 21 Aug 2018 12:36:25 +0200, Ruben Maes <ruben <at> janmaes.com> 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.
This bug report was last modified 6 years and 277 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.