GNU bug report logs - #32494
t incorrectly branching

Previous Next

Package: sed;

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 #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ruben Maes <ruben <at> janmaes.com>
To: Sed Bugs <bug-sed <at> gnu.org>
Subject: t incorrectly branching
Date: Tue, 21 Aug 2018 12:36:25 +0200
[Message part 1 (text/plain, inline)]
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?


Tried on these versions, both did exactly the same:

$ sed --version | head -n1
sed (GNU sed) 4.2.2
sed (GNU sed) 4.5
[Message part 2 (application/pgp-signature, inline)]

This bug report was last modified 6 years and 331 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.