Hi,

putting the minimal useful example in the place of longer quotations:

   $ printf "A\nB\n" | gsed '1b;='
  A
  2
  B
   $ printf "A\nB\n" | sed '1b;='  
  sed: 1: "1b;=": undefined label ''

Martijn van Duren wrote on Wed, Dec 05, 2018 at 09:24:05AM +0100:

> Note that the label should consist of "portable filename
> character set" characters, so adding the semicolon support doesn't break
> compatibility too bad. Although it is a violation, not an extension on
> unspecified behaviour (only unspecified behaviour is for is for
> s/../../w).

Why do you think it is a violation?

POSIX requires that "editing commands other than {...}, a, b, c, i, r, t,
w, :, and # can be followed by a <semicolon>...", but i don't see
anything that specifies what should happen if b is followed by a
semicolon.  So that case seems unspecified.  Our manual page is
somewhat fuzzy with respect to semicolons, but let's fix that after
deciding the behaviour.

Let's look at the likely reasons *why* POSIX does not require
semicolons to work after these commands:

 * a, c, i:
   These take text arguments, which can usefully contain semicolons.

 * #:
   Comments can usefully contain semicolons, too.

 * r, w:
   These take filename arguments, which might contain semicolons;
   it doesn't matter in this context that filenames containing
   semicolons are asking for trouble in other respects.

 * {...}:
   I see no reason for not allowing semicolons here, and indeed:

      $ printf "A\nB\n" | sed -n '{=;};p'
     1
     A
     2
     B

   Same for GNU sed.

That leaves us with b, t, : - which take label arguments.
Support for labels containing semicolons is explicitly
not required and would hardly be useful.

We already support semicolon-continuation after b, t, :,
and so does GNU sed:

   $ printf "A\nB\n" | sed -n '1bL;=;:L;p'
  A
  2
  B

   $ printf "A\nB\n" | sed -n 's/A/C/;tL;=;:L;p'
  C
  2
  B

Removing the existing support for semicolons after b, t, :
does not seem to me to make anything better, but might break
existing scripts or stuff in ports.

So it would seem best to me to only fix the case of b and t without
argument followed by a semicolon, to match GNU, which does the
logical and consistent thing here.

   $ printf "A\nB\n" | gsed '1b;='                
  A
  2
  B
   $ printf "A\nB\n" | gsed 's/A/C/;t;='   
  C
  2
  B

I didn't study your patch yet - is that what it does?

Yours,
  Ingo

Reply via email to