From nobody@FreeBSD.org  Tue Jul 12 21:48:37 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 953FF106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Jul 2011 21:48:37 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 8621A8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Jul 2011 21:48:37 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p6CLmbXf042589
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Jul 2011 21:48:37 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p6CLmb9j042588;
	Tue, 12 Jul 2011 21:48:37 GMT
	(envelope-from nobody)
Message-Id: <201107122148.p6CLmb9j042588@red.freebsd.org>
Date: Tue, 12 Jul 2011 21:48:37 GMT
From: freethread <freethread.sw@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: printf error if format string begin with a dash '-'
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         158846
>Category:       bin
>Synopsis:       printf(1) error if format string begin with a dash '-'
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jilles
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 12 21:50:10 UTC 2011
>Closed-Date:    Wed Jul 13 04:17:56 UTC 2011
>Last-Modified:  Sun Jul 24 17:40:06 UTC 2011
>Originator:     freethread
>Release:        8.2 RELEASE
>Organization:
>Environment:
FreeBSD alpha.freethread.lan 8.2-RELEASE FreeBSD 8.2-RELEASE #1: Wed Mar 30 00:29:15 CEST 2011     root@alpha.freethread.lan:/usr/obj/usr/src/sys/ALPHA  i386

>Description:
using the following command (inline or in script)

    printf "-h, --help       show help"

the printf command raise the error

    printf: illegal option -- h
    usage: printf format [arguments ...]

it should be ok if printf accept options, but this is not the case (as in the previous message):

    usage: printf format [arguments ...]

workarounds:

    printf "\-h, --help       show help"
    printf "%s" "-h, --help       show help"

>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ae 
State-Changed-When: Wed Jul 13 04:16:04 UTC 2011 
State-Changed-Why:  
Not a bug. This case is described in the manual page in CAVEATS section. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158846 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/158846: commit references a PR
Date: Sun, 24 Jul 2011 17:24:35 +0000 (UTC)

 Author: jilles
 Date: Sun Jul 24 17:24:26 2011
 New Revision: 224289
 URL: http://svn.freebsd.org/changeset/base/224289
 
 Log:
   MFC r212374,r221026: printf(1): Document need for "--" before format strings
   starting with "-".
   
   Also move the remark that hexadecimal escapes are not provided to the new
   CAVEATS section.
   
   PR:		158846
 
 Modified:
   stable/8/usr.bin/printf/printf.1
 Directory Properties:
   stable/8/usr.bin/printf/   (props changed)
 
 Modified: stable/8/usr.bin/printf/printf.1
 ==============================================================================
 --- stable/8/usr.bin/printf/printf.1	Sun Jul 24 11:56:39 2011	(r224288)
 +++ stable/8/usr.bin/printf/printf.1	Sun Jul 24 17:24:26 2011	(r224289)
 @@ -332,6 +332,16 @@ command appeared in
  It is modeled
  after the standard library function,
  .Xr printf 3 .
 +.Sh CAVEATS
 +.Tn ANSI
 +hexadecimal character constants were deliberately not provided.
 +.Pp
 +Trying to print a dash ("-") as the first character causes
 +.Nm
 +to interpret the dash as a program argument.
 +.Nm --
 +must be used before 
 +.Ar format .
  .Sh BUGS
  Since the floating point numbers are translated from
  .Tn ASCII
 @@ -343,9 +353,6 @@ The
  .Cm L
  modifier may produce additional precision, depending on the hardware platform.)
  .Pp
 -.Tn ANSI
 -hexadecimal character constants were deliberately not provided.
 -.Pp
  The escape sequence \e000 is the string terminator.
  When present in the argument for the
  .Cm b
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
Responsible-Changed-From-To: freebsd-bugs->jilles 
Responsible-Changed-By: jilles 
Responsible-Changed-When: Sun Jul 24 17:38:46 UTC 2011 
Responsible-Changed-Why:  
I MFCed the man page change mentioning the need for "--" before 
format strings starting with "-". 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158846 
>Unformatted:
