[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#72567: printf: Incorrect description of "%b"
From: |
Keith Thompson |
Subject: |
bug#72567: printf: Incorrect description of "%b" |
Date: |
Sat, 10 Aug 2024 20:05:21 -0700 |
There are three different descriptions of the printf(1) "%b" format:
- printf --help
- man printf.1
- info coreutils printf
As of release 9.5 and the latest version in git (Thu 2024-08-08
c5725c8c4), the first two incorrectly say that octal escapes are
of the form \0 or \0NNN. In fact the \0 can be followed by 0 to 3
octal digits.
In addition, the info documentation is correct but very slightly
unclear. It refers to the octal digits as "000" where the man page
and help message use "NNN"; I suggest that NNN is clearer. It also
says "If ‘\OOO’ is nine-bit value, ignore the ninth bit."; the
backslash is extraneous.
For example, if the description in "printf --help" and the man page
were literally correct, then this command:
/usr/bin/printf "%b" "\01x"
would print a null character, the digit '1', and the letter 'x'.
In fact it correctly prints character 1 (Ctrl-A) and the letter 'x'.
$ /usr/bin/printf "%b" "\01x" | od -c
0000000 001 x
0000002
$
(I use the full path because printf is also a bash builtin function.)
I'll follow up to this email message with a proposed patch.
This will require updating the translation files. I haven't
attempted to do that (I have no idea how), but the changes should
be straightforward.
The patch is 55 lines. Let me know if I need to do a copyright
assignment.
- bug#72567: printf: Incorrect description of "%b",
Keith Thompson <=