From owner-svn-src-head@FreeBSD.ORG Fri Sep 17 00:33:29 2010 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57E651065672; Fri, 17 Sep 2010 00:33:29 +0000 (UTC) (envelope-from obrien@NUXI.org) Received: from dragon.nuxi.org (trang.nuxi.org [74.95.12.85]) by mx1.freebsd.org (Postfix) with ESMTP id D84B28FC08; Fri, 17 Sep 2010 00:33:28 +0000 (UTC) Received: from dragon.nuxi.org (obrien@localhost [127.0.0.1]) by dragon.nuxi.org (8.14.4/8.14.4) with ESMTP id o8H0XSLf014292; Thu, 16 Sep 2010 17:33:28 -0700 (PDT) (envelope-from obrien@dragon.nuxi.org) Received: (from obrien@localhost) by dragon.nuxi.org (8.14.4/8.14.4/Submit) id o8H0XSV1014291; Thu, 16 Sep 2010 17:33:28 -0700 (PDT) (envelope-from obrien) Date: Thu, 16 Sep 2010 17:33:28 -0700 From: "David O'Brien" To: Bruce Evans Message-ID: <20100917003328.GB13653@dragon.NUXI.org> References: <201009091927.o89JReXm022426@svn.freebsd.org> <20100916084442.GB21622@dragon.NUXI.org> <20100916212043.N724@delplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100916212043.N724@delplex.bde.org> X-Operating-System: FreeBSD 9.0-CURRENT X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? User-Agent: Mutt/1.5.16 (2007-06-09) Cc: Juli Mallett , 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-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: obrien@FreeBSD.org List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Sep 2010 00:33:29 -0000 On Thu, Sep 16, 2010 at 09:36:43PM +1000, Bruce Evans wrote: > On Thu, 16 Sep 2010, David O'Brien wrote: >> Is a sentence or two a burden to the man page vs. saving someone the time >> I spent trying to figure out why printf(1) kept throwing up errors? > > WHat about the lesser burder on a character or two for putting -- in the > synopsis where it is more visible: > > printf [--] format [arguments ...] > > POSIX doesn't do this, and it doesn't seem to say anything about the > problem of a leading - in the format either. Presumably its general > utilities specs require _all_ utilities to support "--". That would be fine for me too, if its prefered that way. Index: printf.1 =================================================================== --- printf.1 (revision 212773) +++ printf.1 (working copy) @@ -43,6 +43,7 @@ .Nd formatted output .Sh SYNOPSIS .Nm +.Op Fl - .Ar format Op Ar arguments ... .Sh DESCRIPTION The @@ -51,6 +52,13 @@ utility formats and prints its arguments of the .Ar format . The +.Fl - +option prevents any interpretation of a leading dash ("-") character in +.Ar format +as a +.Nm +program option. +The .Ar format is a character string which contains three types of objects: plain characters, which are simply copied to standard output, character escape sequences which @@ -355,10 +363,3 @@ 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 wonder if > there are any utilities that don't use getopt(3) and as a result aren't > POSIX conformant since they don't support "--" and also need to support > a first argument starting with "-" (which won't cause problems because dd(1) is the only thing coming to mind, but it doesn't need to handle argments starting with "-". I believe our find(1) has a problem: $ cd /tmp $ mkdir ./- $ touch ./-/foo $ find -- - -name foo find -- - -name foo usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression] find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression] -- -- David (obrien@FreeBSD.org)