NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/58534: Incorrect information in src/usr.bin/printf/printf.c comment
>Number: 58534
>Category: bin
>Synopsis: Incorrect information in src/usr.bin/printf/printf.c comment
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Aug 01 09:45:00 +0000 2024
>Originator: emanuele6 (Emanuele Torre)
>Release: $NetBSD: printf.c,v 1.55 2024/07/18 12:08:11 wiz Exp $
>Organization:
>Environment:
>Description:
The comments in printf.c regarding -- are wrong:
http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/printf/printf.c?rev=1.55
/*
* printf does not comply with Posix XBD 12.2 - there are no opts,
* not even the -- end of options marker. Do not run getopt().
*/
if (argc > 2 && strchr(argv[1], '%') == NULL) {
int o;
/*
* except that if there are multiple args and
* the first (the nominal format) contains no '%'
* conversions (which we will approximate as no '%'
* characters at all, conversions or not) then the
* results are unspecified, and we can do what we
* like. So in that case, for some backward compat
* to scripts which (stupidly) do:
* printf -- format args
* process this case the old way.
*/
I also used to think that "OPTIONS None." for all utilities meant that
the utility should follow XDB 12.2 and should not implement "--";
however that only applies to shell special builtins per XCU 2.15:
https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/V3_chap02.html#tag_19_15
> [...]
> Some of the special built-ins are described as conforming to XBD 12.2
> Utility Syntax Guidelines . For those that are not, the requirement in
> 1.4 Utility Description Defaults that "--" be recognized as a first
> argument to be discarded does not apply and a conforming application
> shall not use that argument.
> [...]
For all other (not shell special builtins) utilities, like printf, -- is
required as per the aforementioned XCU 1.4:
https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/V3_chap01.html#tag_18_04
> [...]
> OPTIONS
> [...]
> Default Behavior: When this section is listed as "None.", it means
> that the implementation need not support any options. Standard
> utilities that do not accept options, but that do accept operands,
> shall recognize "--" as a first argument to be discarded.
> [...]
I have also checked POSIX Issue 6, and POSIX Issue 7 and that XCU 1.4
note was also present.
Issue 7 XCU 1.4
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html#tag_17_04
Issue 6 XCU 1.11
https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html#tag_01_11
So the code should be fine: printf could still make printf -- print --
as an extension since printf with no arguments is not specified, but the
information in the comment is wrong/misleading and should be removed in
my opinion.
o/
emanuele6
>How-To-Repeat:
>Fix:
Home |
Main Index |
Thread Index |
Old Index