On Mon, 21 Apr 2025 at 12:13 Michael Forney, <mforney_AT_mforney.org> wrote:
> unescape() is used by several tools, in particular printf(1) and
> tr(1), which should stop the octal escape at a maximum of 3 digits:
>
> printf(1)
> > In addition to the escape sequences shown in XBD 5. File Format
> > Notation ('\\', '\a', '\b', '\f', '\n', '\r', '\t', '\v'), "\ddd",
> > where ddd is a one, two, or three-digit octal number, shall be
> > written as a byte with the numeric value specified by the octal
> > number.
Unfortunately POSIX specifies that printf(1)'s %b conversion specifier
interprets octal as \0ddd. IIRC that is why unescape uses 4 now.
That should probably be an argument that can be passed in or configurable
in some way so we can support that correctly. Or open an issue with
the Austin Group to ask about it (I haven't searched to see if one
already exists).
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/printf.html
> 7. An additional conversion specifier character, b, shall be supported
> as follows. The argument shall be taken to be a string that can contain
> <backslash>-escape sequences. The following <backslash>-escape sequences
> shall be supported:
...
> - "\0ddd", where ddd is a zero, one, two, or three-digit octal number
> that shall be converted to a byte with the numeric value specified by
> the octal number.
Received on Wed Apr 30 2025 - 22:13:38 CEST