bug#21749: printf --help not working
tag 21749 notabug thanks On 10/24/2015 04:36 AM, Andreas Kern wrote: > steps to reproduce > > run `printf --help` That's probably running your shell's builtin printf, rather than the one from coreutils. Try: env printf --help or /bin/printf --help and to see the difference, try: type printf > comment: > I checked it on ubuntu and on arch, both don't print the help. I checked > the source package on ubuntu and there is code for that in printf.c If you read the source code, you may also notice that coreutils' 'printf --help' includes this text: $ env printf --help | tail and all C format specifications ending with one of diouxXfeEgGcs, with ARGUMENTs converted to proper type first. Variable widths are handled. NOTE: your shell may have its own version of printf, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports. GNU coreutils online help: <http://www.gnu.org/software/coreutils/> For complete documentation, run: info coreutils 'printf invocation' As such, I'm closing this as not a bug, although you should feel free to make further comments. Also, future bash releases may be adding support for 'printf --help' with the bash builtin printf, to match the fact that ksh builtin printf already accepts that option; but that won't help for dash, which is Ubuntu's /bin/sh. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
bug#21749: printf --help not working
steps to reproduce run `printf --help` actual output (nothing) expected output the help message comment: I checked it on ubuntu and on arch, both don't print the help. I checked the source package on ubuntu and there is code for that in printf.c
[PATCH] doc: improve the echo and printf help on escapes
* src/printf.c (usage): Merge strings with echo to aid translators. Move the description for \NNN beside the other numeric escape codes. Don't mention character as that suggests character conversion. * src/echo.c (usage): Likewise. Also mention the \xHH escape sequence. attached... cheers, Pádraig. From 24a736d4b205ba915b3fa2916d8b9fc9513ac444 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?= p...@draigbrady.com Date: Wed, 28 Oct 2009 10:59:05 + Subject: [PATCH] doc: improve the echo and printf help on escapes * src/printf.c (usage): Merge strings with echo to aid translators. Move the description for \NNN beside the other numeric escape codes. Don't mention character as that suggests character conversion. * src/echo.c (usage): Likewise. Also mention the \xHH escape sequence. --- src/echo.c |9 ++--- src/printf.c |6 ++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/echo.c b/src/echo.c index 90b9786..afd722c 100644 --- a/src/echo.c +++ b/src/echo.c @@ -63,12 +63,11 @@ Echo the STRING(s) to standard output.\n\ \n\ If -e is in effect, the following sequences are recognized:\n\ \n\ - \\0NNN the character whose ASCII code is NNN (octal)\n\ +), stdout); + fputs (_(\ backslash\n\ \\a alert (BEL)\n\ \\b backspace\n\ -), stdout); - fputs (_(\ \\c produce no further output\n\ \\f form feed\n\ \\n new line\n\ @@ -76,6 +75,10 @@ If -e is in effect, the following sequences are recognized:\n\ \\t horizontal tab\n\ \\v vertical tab\n\ ), stdout); + fputs (_(\ + \\0NNN byte with octal value NNN (1 to 3 digits)\n\ + \\xHH byte with hexadecimal value HH (1 to 2 digits)\n\ +), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); emit_ancillary_info (); } diff --git a/src/printf.c b/src/printf.c index f6f86a5..e9d182a 100644 --- a/src/printf.c +++ b/src/printf.c @@ -101,22 +101,20 @@ Print ARGUMENT(s) according to FORMAT, or execute according to OPTION:\n\ FORMAT controls the output as in C printf. Interpreted sequences are:\n\ \n\ \\\ double quote\n\ - \\NNNcharacter with octal value NNN (1 to 3 digits)\n\ - backslash\n\ ), stdout); fputs (_(\ + backslash\n\ \\a alert (BEL)\n\ \\b backspace\n\ \\c produce no further output\n\ \\f form feed\n\ -), stdout); - fputs (_(\ \\n new line\n\ \\r carriage return\n\ \\t horizontal tab\n\ \\v vertical tab\n\ ), stdout); fputs (_(\ + \\NNNbyte with octal value NNN (1 to 3 digits)\n\ \\xHHbyte with hexadecimal value HH (1 to 2 digits)\n\ \\u Unicode (ISO/IEC 10646) character with hex value (4 digits)\n\ \\U Unicode character with hex value (8 digits)\n\ -- 1.6.2.5
Re: [PATCH] doc: improve the echo and printf help on escapes
Pádraig Brady wrote: * src/printf.c (usage): Merge strings with echo to aid translators. Move the description for \NNN beside the other numeric escape codes. Don't mention character as that suggests character conversion. * src/echo.c (usage): Likewise. Also mention the \xHH escape sequence. ... Subject: [PATCH] doc: improve the echo and printf help on escapes * src/printf.c (usage): Merge strings with echo to aid translators. Move the description for \NNN beside the other numeric escape codes. Don't mention character as that suggests character conversion. * src/echo.c (usage): Likewise. Also mention the \xHH escape sequence. Looks fine. Thanks!
Re: [PATCH] doc: improve the echo and printf help on escapes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Jim Meyering on 10/28/2009 5:31 AM: * src/echo.c (usage): Likewise. Also mention the \xHH escape sequence. While we're at it, bash's builtin echo supports \E as an escape for ascii ESC; do we want to add that as well, for consistency across GNU projects? - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkroMMIACgkQ84KuGfSFAYAF0ACgsxrSjBFwMYDMCfFfw7h6q2gw A14AoJzA43HS/VMbRaBcc9+eBf6a86Nd =XJ/1 -END PGP SIGNATURE-
Re: [PATCH] doc: improve the echo and printf help on escapes
Eric Blake wrote: According to Jim Meyering on 10/28/2009 5:31 AM: * src/echo.c (usage): Likewise. Also mention the \xHH escape sequence. While we're at it, bash's builtin echo supports \E as an escape for ascii ESC; do we want to add that as well, for consistency across GNU projects? I've been reluctant to modify echo, thinking that it gets so little use it's not worth the trouble. And besides, it's been deprecated in favor of printf forever. However, if you'd like to make the change, go ahead. Consistency can be handy, even in a deprecated tool that people still use as much as echo.
Re: [PATCH] doc: improve the echo and printf help on escapes
Eric Blake wrote: According to Jim Meyering on 10/28/2009 5:31 AM: * src/echo.c (usage): Likewise. Also mention the \xHH escape sequence. While we're at it, bash's builtin echo supports \E as an escape for ascii ESC; do we want to add that as well, for consistency across GNU projects? Great minds think alike :) Note gcc, perl, bash, ksh and tcsh support \e while POSIX, dash python do not. commit 983b46bfa497aef12680e4a732cf5556de96a053 Author: Pádraig Brady p...@draigbrady.com Date: Tue Oct 27 10:04:34 2009 + echo, printf: interpret \e as the Escape character * src/printf.c (?): Output \x1B when \e encountered. * src/echo.c (?): Likewise. * doc/coreutils.texi (echo invocation): Add \e to the list. * NEWS: Mention the change in behaviour. diff --git a/NEWS b/NEWS index 315ae5f..87b5d11 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,8 @@ GNU coreutils NEWS-*- outline -*- with the invoked command failing with status 1. Likewise, nohup fails with status 125 instead of 127. + echo and printf now interpret \e as the Escape character (0x1B). + ** New features md5sum --check now also accepts openssl-style checksums. diff --git a/doc/coreutils.texi b/doc/coreutils.texi index c54ffb8..f1a95f3 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -10796,6 +10796,8 @@ alert (bell) backspace @item \c produce no further output +...@item \e +escape @item \f form feed @item \n diff --git a/src/echo.c b/src/echo.c index 90b9786..65e8c80 100644 --- a/src/echo.c +++ b/src/echo.c @@ -70,6 +70,7 @@ If -e is in effect, the following sequences are recognized:\n\ ), stdout); fputs (_(\ \\c produce no further output\n\ + \\e escape\n\ \\f form feed\n\ \\n new line\n\ \\r carriage return\n\ @@ -203,6 +204,7 @@ just_echo: case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'c': exit (EXIT_SUCCESS); +case 'e': c = '\x1B'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; diff --git a/src/printf.c b/src/printf.c index f6f86a5..540d7db 100644 --- a/src/printf.c +++ b/src/printf.c @@ -25,6 +25,7 @@ \a = alert (bell) \b = backspace \c = produce no further output + \e = escape \f = form feed \n = new line \r = carriage return @@ -108,6 +109,7 @@ FORMAT controls the output as in C printf. Interpreted sequences are:\n\ \\a alert (BEL)\n\ \\b backspace\n\ \\c produce no further output\n\ + \\e escape\n\ \\f form feed\n\ ), stdout); fputs (_(\ @@ -200,6 +202,9 @@ print_esc_char (char c) case 'c': /* Cancel the rest of the output. */ exit (EXIT_SUCCESS); break; +case 'e': /* Escape. */ + putchar ('\x1B'); + break; case 'f': /* Form feed. */ putchar ('\f'); break; @@ -256,7 +261,7 @@ print_esc (const char *escstart, bool octal_0) esc_value = esc_value * 8 + octtobin (*p); putchar (esc_value); } - else if (*p strchr (\\\abcfnrtv, *p)) + else if (*p strchr (\\\abcefnrtv, *p)) print_esc_char (*p++); else if (*p == 'u' || *p == 'U') {
Re: [PATCH] doc: improve the echo and printf help on escapes
Pádraig Brady wrote: Eric Blake wrote: According to Jim Meyering on 10/28/2009 5:31 AM: * src/echo.c (usage): Likewise. Also mention the \xHH escape sequence. While we're at it, bash's builtin echo supports \E as an escape for ascii ESC; do we want to add that as well, for consistency across GNU projects? Great minds think alike :) Note gcc, perl, bash, ksh and tcsh support \e while POSIX, dash python do not. ;-) Looks fine. Thanks! commit 983b46bfa497aef12680e4a732cf5556de96a053 Author: Pádraig Brady p...@draigbrady.com Date: Tue Oct 27 10:04:34 2009 + echo, printf: interpret \e as the Escape character * src/printf.c (?): Output \x1B when \e encountered. * src/echo.c (?): Likewise. * doc/coreutils.texi (echo invocation): Add \e to the list. * NEWS: Mention the change in behaviour.
Re: printf --help
[EMAIL PROTECTED] (Karl Berry) wrote: The --help message for printf (coreutils 6.9) starts with this: Usage: /usr/local/gnu/bin/printf FORMAT [ARGUMENT]... or: /usr/local/gnu/bin/printf OPTION Print ARGUMENT(s) according to FORMAT. --help display this help and exit --version output version information and exit I'd like to suggest a tiny change, something like: Print ARGUMENT(s) according to FORMAT, or execute according to OPTION: Thanks. I've done that. ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
printf --help
The --help message for printf (coreutils 6.9) starts with this: Usage: /usr/local/gnu/bin/printf FORMAT [ARGUMENT]... or: /usr/local/gnu/bin/printf OPTION Print ARGUMENT(s) according to FORMAT. --help display this help and exit --version output version information and exit I'd like to suggest a tiny change, something like: Print ARGUMENT(s) according to FORMAT, or execute according to OPTION: Right now, there's nothing explicitly saying that --help and --version are the options. I admit it's unlikely to be a point of confusion (especially for anyone who can figure out how to invoke coreutils printf in the first place :), but is there any harm in saying it explicitly? Thanks for coreutils :). karl ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils