From owner-svn-src-all@FreeBSD.ORG Thu Sep 9 19:53:04 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66D6D10656FA; Thu, 9 Sep 2010 19:53:04 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 2C17C8FC19; Thu, 9 Sep 2010 19:53:04 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 607F81DD656; Thu, 9 Sep 2010 21:53:02 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 54909172E5; Thu, 9 Sep 2010 21:53:02 +0200 (CEST) Date: Thu, 9 Sep 2010 21:53:02 +0200 From: Jilles Tjoelker To: "David E. O'Brien" Message-ID: <20100909195302.GA48144@stack.nl> References: <201009091927.o89JReXm022426@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201009091927.o89JReXm022426@svn.freebsd.org> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r212374 - head/usr.bin/printf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Sep 2010 19:53:04 -0000 On Thu, Sep 09, 2010 at 07:27:40PM +0000, David E. O'Brien wrote: > Author: obrien > Date: Thu Sep 9 19:27:40 2010 > New Revision: 212374 > URL: http://svn.freebsd.org/changeset/base/212374 > Log: > Note bug in trying to printf(1) things like: '-%s\n' "foo" > Modified: > head/usr.bin/printf/printf.1 > Modified: head/usr.bin/printf/printf.1 > ============================================================================== > --- head/usr.bin/printf/printf.1 Thu Sep 9 18:51:50 2010 (r212373) > +++ head/usr.bin/printf/printf.1 Thu Sep 9 19:27:40 2010 (r212374) > @@ -355,3 +355,10 @@ Multibyte characters are not recognized > a problem if > .Ql % > can appear inside a multibyte character). > +.Pp > +Trying to print a dash ("-") as the first character causes > +.Nm > +to interpet the dash as a program argument. > +.Nm -- > +must be used before > +.Ar format . I do not consider this a bug. POSIX requires printf to recognize -- and pretty much all current implementations conform to this. Causing an error for unrecognized options allows us to add options later on, without fear of breaking scripts that use format strings starting with a dash without -- protection. Needing -- is not particularly onerous here as format strings are usually constants. A caveat could be added, but it is really echo(1) that is inconsistent by not treating -- specially. The printf utility is consistent with most other utilities in requiring --. FWIW, the omission of hexadecimal character constants does not belong in the BUGS section either. They are deliberately not provided, therefore their omission is not a bug. (One reason is that there is no way to force termination of such a sequence, unlike C where you can do things like "\x1b" "c".) -- Jilles Tjoelker