Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15204 > unrolled thread

Re: Incorrect option processing in builtin printf(1)

Started byChet Ramey <chet.ramey@case.edu>
First post2019-07-22 16:16 -0400
Last post2019-07-22 16:16 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Incorrect option processing in builtin printf(1) Chet Ramey <chet.ramey@case.edu> - 2019-07-22 16:16 -0400

#15204 — Re: Incorrect option processing in builtin printf(1)

FromChet Ramey <chet.ramey@case.edu>
Date2019-07-22 16:16 -0400
SubjectRe: Incorrect option processing in builtin printf(1)
Message-ID<mailman.2027.1563826639.2688.bug-bash@gnu.org>
On 7/22/19 1:56 PM, kre@munnari.OZ.AU wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: netbsd
> Compiler: gcc
> Compilation CFLAGS: -O2 -D_FORTIFY_SOURCE=2 -I/usr/include -Wno-parentheses -Wno-format-security
> uname output: NetBSD jinx.noi.kre.to 8.99.30 NetBSD 8.99.30 (1.1-20190114) #9: Mon Jan 14 13:29:08 ICT 2019  kre@onyx.coe.psu.ac.th:/usr/obj/testing/kernels/amd64/JINX amd64
> Machine Type: x86_64--netbsd
> 
> Bash Version: 5.0
> Patch Level: 7
> Release Status: release
> 
> Description:
> 	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.
> 
> 	So
> 		printf ---		should print three - chars to stdout
> 		printf -%d 3		should print -3 to stdout
> 	those do not work in bash (nor do any similar cases), even when bash
> 	is in posix mode.

No. POSIX allows additional options as extensions, even when the syntax
description OPTIONS section says "None." ("need not" is not the same as
"must not").

Conforming applications are required to use `--' before any operands that
begin with a dash:

"The requirement for recognizing "--" is because conforming applications
need a way to shield their operands from any arbitrary options that the
implementation may provide as an extension. For example, if the standard
utility foo is listed as taking no options, and the application needed to
give it a pathname with a leading <hyphen-minus>, it could safely do it as:

foo -- -myfile

and avoid any problems with -m used as an extension."

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html#tag_17_04

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web