On 22/07/2026 15:45, Dmitri Seletski wrote:
Fantastic!
Thanks!
On 22/07/2026 13:05, Pádraig Brady wrote:
On 20/07/2026 17:10, Pádraig Brady wrote:
The "see also" has a reference to printf(3),
which you can drill down to directly depending on you man page viewer,
or view directly with `man 3 printf`.
But I agree we should show that reference directly in the text.
We need to be careful not to repeat too much info from the (large)
printf(3) page,
but I also agree that we could provide a little more info here.
I'll look at:
Using our recently improved man table formatting to present a
conversion summary.
Including at least mentioning that flags are supported.
Also an EXAMPLES section would be useful here I think to show
supported combinations.
I'll apply the attached later, which adds:
CONVERSION Shell format example Output
%s '[%10s]' 'left pad' [ left pad]
%s '[%-10s]' 'right pad' [right pad ]
%c %s '%c %.3s' un unibyte u uni
%d %i "%'d ;%i04i" 1234 '-1' 1,234 ;-001
%o '%#o' $((2#110100100)) 0644
%u '%u' 0xFFFFFFFF 4294967295
%x '0x%08x' 11259375 0x00abcdef
%a %f '%1$a %1$f' 0.0009765625 0x8p-13 0.000977
%e %f '%1$e %1$f' 123.45678 1.234568e+02 123.456789
%g '%1$g %1$.2g' 1.2345678e3 1234.57 1.2e+03
%b '%b' 'food\bbar' foobar
%q '%q ' 'a' ';b' $'c\n' a ';b' 'c'$'\n'
I added blank lines to group the above into,
string, integer, float, and other groups.
I also pushed the attached to improve the
printf reference tables in the info docs.
cheers,
Padraig
From dc9ee52536c0af435c27c193e429d380e5c7041f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Wed, 22 Jul 2026 15:49:11 +0100
Subject: [PATCH] doc: echo,printf: detail exactly which escapes are supported
* doc/coreutils.texi (echo invocation): Parameterize the escape list.
(printf invocation): Remove the C escape reference as it mentions
\' which we don't support, and doesn't mention \e which we do support
(and GCC also does). Instead directly present the escape list
as done for the echo command, adjusted accordingly.
---
doc/coreutils.texi | 57 ++++++++++++++++++++++++++++++----------------
1 file changed, 38 insertions(+), 19 deletions(-)
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index e90fb3e14..27690aa93 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -12873,39 +12873,54 @@ Do not output the trailing newline.
Enable interpretation of the following backslash-escaped characters in
each @var{string}:
+@macro escapeSequences
@table @samp
-@item \a
+@item \\\\
+backslash
+@ifset PRINTF_COMMAND
+@item \\"
+double quote
+@end ifset
+@item \\a
alert (bell)
-@item \b
+@item \\b
backspace
-@item \c
+@item \\c
produce no further output
-@item \e
+@item \\e
escape
-@item \f
+@item \\f
form feed
-@item \n
+@item \\n
newline
-@item \r
+@item \\r
carriage return
-@item \t
+@item \\t
horizontal tab
-@item \v
+@item \\v
vertical tab
-@item \\
-backslash
-@item \0@var{nnn}
+@ifclear PRINTF_COMMAND
+@item \\0@var{nnn}
the eight-bit value that is the octal number @var{nnn}
(zero to three octal digits), if @var{nnn} is
a nine-bit value, the ninth bit is ignored
-@item \@var{nnn}
+@end ifclear
+@item \\@var{nnn}
the eight-bit value that is the octal number @var{nnn}
(one to three octal digits), if @var{nnn} is
a nine-bit value, the ninth bit is ignored
-@item \x@var{hh}
+@item \\x@var{hh}
the eight-bit value that is the hexadecimal number @var{hh}
(one or two hexadecimal digits)
+@ifset PRINTF_COMMAND
+@item \\u@var{hhhh}
+Unicode (ISO/IEC 10646) character with hex value HHHH (4 digits)
+@item \\U@var{hhhhhhhh}
+Unicode character with hex value HHHHHHHH (8 digits)
+@end ifset
@end table
+@end macro
+@escapeSequences
@optItem{echo,-E,}
@cindex backslash escapes
@@ -12950,10 +12965,16 @@ in a way that is mostly similar to the C @samp{printf} function,
and C language escape sequence processing.
@xref{Output Conversion Syntax,, @command{printf} format directives,
libc, The GNU C Library Reference Manual}, for details.
-See also @uref{https://en.cppreference.com/w/c/language/escape,
-C99 string escapes:}.
-Examples of supported conversion specifiers and flags are:
+@mayConflictWithShellBuiltIn{printf}
+
+Supported escape sequences are:
+
+@set PRINTF_COMMAND
+@escapeSequences
+@clear PRINTF_COMMAND
+
+Supported conversion specifiers with examples are:
@example
CONVERSION Shell format example Output
@@ -12975,8 +12996,6 @@ CONVERSION Shell format example Output
%q '%q ' 'a' ';b' $'c\n' a ';b' 'c'$'\n'
@end example
-@mayConflictWithShellBuiltIn{printf}
-
The differences from the C @samp{printf} function are:
@itemize @bullet
--
2.55.0