Bug#961740: printf attempts to parse options and fails to print --help
On Friday, 29 May 2020 19:35:06 CEST Jakub Wilk wrote: > I think you're misinterpreting the standard. If it really meant that > implementations must not support any options, it would say so > explicitly, like it does for echo: > > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html Indeed, you are correct. In that case printf may have >= 0 options and whether options are parsed at all is unspecified. This also explains the lack of any reference to "Section 12.2, Utility Syntax Guidelines". Apologies for the noise. -- Melvin Vermeeren signature.asc Description: This is a digitally signed message part.
Bug#961740: printf attempts to parse options and fails to print --help
* Melvin Vermeeren , 2020-05-28, 17:17: POSIX specifies printf has no options, meaning this should print "--help". Arguments parsing must simply not be attempted at all in order to be compliant as far as I know. $ /usr/bin/printf --help Usage: /usr/bin/printf FORMAT [ARGUMENT]... or: /usr/bin/printf OPTION I think you're misinterpreting the standard. If it really meant that implementations must not support any options, it would say so explicitly, like it does for echo: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html -- Jakub Wilk
Bug#961740: printf attempts to parse options and fails to print --help
On Thu, May 28, 2020 at 05:56:09PM +0200, Melvin Vermeeren wrote: On Thursday, 28 May 2020 17:50:20 CEST Michael Stone wrote: Yes, running printf with the single argument --help will print help. A portable and posix-compliant alternative would be to run "printf '%s' --help". This is extremely unlikely to change. This is not the only problem that occurs, printing -- does not work either. same solution will work! Coreutils should aim for POSIX compliancy, perhaps it would be better if I take this bug upstream? You certainly can, but they will probably also consider this to be of purely academic interest. The solution I provided above is the only portable way to make what you're trying to do work, regardless of POSIX. Even if I changed the debian package today, you'd have to continue to do the above basically forever because of the enormous installed base of implementations don't work the way you're requesting. And not having the help output will likely confuse more people who won't know why it wouldn't work.
Bug#961740: printf attempts to parse options and fails to print --help
Package: coreutils Version: 8.30-3 Hi, POSIX specifies printf has no options, meaning this should print "--help". Arguments parsing must simply not be attempted at all in order to be compliant as far as I know. $ /usr/bin/printf --help Usage: /usr/bin/printf FORMAT [ARGUMENT]... or: /usr/bin/printf OPTION ... >From https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html: > SYNOPSIS > >printf format [argument...] > > ... > > OPTIONS > >None. Bash also does not handle this correctly. However bash is not POSIX sh, hence it is not a bug. (It appears bash some some "printf -v var" extension.) I also tested zsh, which appears to be fully compliant. Thanks, -- Melvin Vermeeren signature.asc Description: This is a digitally signed message part.