GNU bug report logs - #20095
conditional branching

Previous Next

Package: sed;

Reported by: Erik Popp <epopp <at> i2pmail.org>

Date: Thu, 12 Mar 2015 06:54:01 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20095 in the body.
You can then email your comments to 20095 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#20095; Package sed. (Thu, 12 Mar 2015 06:54:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Erik Popp <epopp <at> i2pmail.org>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Thu, 12 Mar 2015 06:54:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Erik Popp <epopp <at> i2pmail.org>
To: bug-sed <at> gnu.org
Subject: conditional branching
Date: Thu, 12 Mar 2015 02:42:07 +0000 (UTC)
[Message part 1 (text/html, inline)]
[filesystem-events.log (text/x-log, attachment)]
[log-filter.sed (text/plain, attachment)]

Information forwarded to bug-sed <at> gnu.org:
bug#20095; Package sed. (Thu, 12 Mar 2015 09:02:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Davide Brini <dave_br <at> gmx.com>
To: bug-sed <at> gnu.org
Subject: Re: bug#20095: conditional branching
Date: Thu, 12 Mar 2015 10:01:31 +0100
On Thu, 12 Mar 2015 02:42:07 +0000 (UTC), Erik Popp <epopp <at> i2pmail.org>
wrote:

> I'm using sed to verify that a log file is in the correct format, to make
> it impossible for crafted input to cause any problems in a shell script.
> 
> I'm stumped, and the only explanation that I can think of for why my
> script isn't working is that sed's "t" command is not working properly.
> 
> If I comment out any 2 of the 3 main commands, the output is as expected:
> white space stripper always "succeeds", and thus the script jumps to the
> success section curly brace detector jumps to the "success" section if
> triggered.  otherwise, the t command fails, because there wasn't a
> substitution in the first place entry converter succeeds if format of
> entry is valid, assuming that there isn't any surrounding white space
> However, if I un-comment all 3 of the main commands, the script doesn't
> fail when input is invalid.  Instead, it spits out the un-transformed
> invalid input, as if it was valid.
> 
> Am I missing something, or is this a bug?

If I understand correctly (I've had only a quick look at the code): the
description for the "t" command says

     Branch to LABEL only if there has been a successful `s'ubstitution
     since the last input line was read or conditional branch was taken.
     The LABEL may be omitted, in which case the next cycle is started.

(note: since the last conditional branch was taken) which, in simple terms,
means that with this sample code:

s/foo/bar/
s/xxx/yyy/
t successxxx

the code will branch to :successxxx if *either* substitution succeeds.
For this reason it's sometimes needed to "reset" the state of the "t"
command, so to speak, as follows:

s/foo/bar/
t successfoo
:successfoo
s/xxx/yyy/
t successxxx

with this modification, the code will branch to :successxxx only if the
last substitution succeeds.

-- 
D.




Information forwarded to bug-sed <at> gnu.org:
bug#20095; Package sed. (Sat, 14 Mar 2015 20:44:02 GMT) Full text and rfc822 format available.

Message #11 received at 20095 <at> debbugs.gnu.org (full text, mbox):

From: Erik Popp <epopp <at> i2pmail.org>
To: 20095 <at> debbugs.gnu.org
Subject: sed conditional branching
Date: Sat, 14 Mar 2015 19:47:59 +0000 (UTC)
[Message part 1 (text/html, inline)]
[log-filter.sed (text/plain, attachment)]
[filesystem-events.log (text/plain, attachment)]

Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Sun, 10 May 2015 17:17:02 GMT) Full text and rfc822 format available.

Notification sent to Erik Popp <epopp <at> i2pmail.org>:
bug acknowledged by developer. (Sun, 10 May 2015 17:17:02 GMT) Full text and rfc822 format available.

Message #16 received at 20095-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Erik Popp <epopp <at> i2pmail.org>, 20095-done <at> debbugs.gnu.org
Subject: Re: sed conditional branching
Date: Sun, 10 May 2015 10:16:05 -0700
tags 20095 notabug
thanks

Davide Brini's analysis at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20095#8
is correct. "t" works like this:

't LABEL'
     Branch to LABEL only if there has been a successful 's'ubstitution
     since the last input line was read or conditional branch was taken.
     The LABEL may be omitted, in which case the next cycle is started.

yet your script expects it to work differently.

Hence, I'm marking this issue as a non-bug and closing it.
However, you are welcome to reply here; any comments will
be logged at https://bugs.gnu.org/20095.




Information forwarded to bug-sed <at> gnu.org:
bug#20095; Package sed. (Mon, 11 May 2015 05:39:02 GMT) Full text and rfc822 format available.

Message #19 received at 20095 <at> debbugs.gnu.org (full text, mbox):

From: Erik Popp <epopp <at> i2pmail.org>
To: 20095 <at> debbugs.gnu.org
Subject: Thanks for clarifying
Date: Mon, 11 May 2015 00:54:39 +0000 (UTC)
Thanks for clarifying.  It turns out that the bug was in the tutorial I 
read, not sed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 08 Jun 2015 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 295 days ago.

Previous Next


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