Subject: bug#21250: sed: empty label for :/b/t commands

From: Jim Meyering <[email-masked]>
Date: Sat, 22 Aug 2015 22:02:42 -0700

On Thu, Aug 13, 2015 at 7:37 AM, Stephane Chazelas
<[email-masked]> wrote:
> Hello.
>
> Not really a bug as such, just a note of how a corner case of
> GNU sed syntax parsing is being misused:
>
> Recently, on unix.stackexchange.com, I've seen several times
> people (might have been the same person every time) doing things
> like:
>
> sed ':;s/../../;t'
>
> That is, define an empty label, and branch on it later on.
>
> There's an example at
> https://unix.stackexchange.com/revisions/223003/1
> https://unix.stackexchange.com/a/223003
>
> as per the documentation, it's not meant to work that way. The
> label for ":" is not optional and "t" or "b" without label are
> meant to jump to the end (start a new label).

Thank you for pointing that out.
I am preparing a patch to remove that functionality, making sed do
this, instead:

  $ sed :
  sed: -e expression #1, char 1: ":" lacks a label

Does anyone feel differently?
However, note that I have not surveyed other sed implementations.

> I've warned that person that relying on an unspecified behaviour
> was not a good idea as it may no longer work in the future, but
> now if several people follow his example, that may mean it will
> become a de-facto feature of GNU sed, and then the sed
> maintainers would have to make sure it's not removed in future
> versions (and document it).
>
> So maybe it would be a good idea to either remove that
> "feature" or make it an official one before its usage becomes
> widespread.