tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: printf(1), sh(1), POSIX.2 and octal escape sequences



Le Wed, Jun 28, 2023 at 04:24:20PM +0000, RVP a écrit :
> On Wed, 28 Jun 2023, tlaronde%polynum.com@localhost 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.
> 

OK, in this case if this is specified somewhere, and linked to the way
lexers behave, I will go with this. (It would be good if POSIX in a 
revision could suppress all the "singular" explanations of octal, put
a common specified definition in one place, and link to it.)
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


Home | Main Index | Thread Index | Old Index