On Wed, 28 Jun 2023, tlaro...@polynum.com wrote:

But you can't: from the syntax given, \777 is a perfectly valid \77
octal sequence followed by the character '7'.


That would be a very surprising way to resolve the ambiguity which is
present here. There are others when it comes to octal notation:

Single-digit octal escapes can be confused with regexp back-references, so
POSIX says octal escapes must have at least 2 digits in certain situations.

As for resolving \777 as \777 and not \77'7 is this note in the EXTENDED
DESCRIPTION for tr(1) (I knew I had read this somewhere in my travels through
POSIX-land):

   \octal
          Octal sequences can be used to represent characters with specific
          coded values. An octal sequence shall consist of a <backslash>
          followed by the _longest_ sequence of one, two, or three-octal-digit
          characters (01234567).

   (my emphasis)

What's good for the goose is also good for the gander, I say.

Cheers!
-RVP

Reply via email to