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 (obr...@freebsd.org) _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"