[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Incorrect option processing in builtin printf(1)
From: |
Eric Blake |
Subject: |
Re: Incorrect option processing in builtin printf(1) |
Date: |
Mon, 22 Jul 2019 14:55:05 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 7/22/19 2:48 PM, Stephane Chazelas wrote:
> 2019-07-23 00:56:59 +0700, kre@munnari.OZ.AU:
> [...]
>> POSIX specifies that printf(1) has no options, and by not
>> specifying that it is intended to comply with XBD 12.2 effectivly
>> says that it is not. That is, in printf, the first arg is
>> always the format string, whatever it contains.
> [...]
>
> If that was the case, then that would be bug in the POSIX
> specification. I can't find a single printf implementations
> where printf -- outputs -- (I tried bash, zsh, ksh93, GNU, yash,
> busybox, busybox ash, Solaris /bin/printf).
>
> Even if POSIX didn't mandate
>
> printf -- -%s x
>
> to output -x, I'd say it would be a bug in the POSIX
> specification (it looks like it is).
POSIX _does_ mandate 'printf -- -%s x' to output exactly '-x', by virtue
of the fact that it mandates all utilities (other than special builtins)
with the specification 'OPTIONS None.' to parse and ignore '--' as the
end of options, whether or not the utility takes options as an
extension. If NetBSD broke that behavior, that is a bug in NetBSD's
shell, not bash nor POSIX.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature