Date: Thu, 16 Sep 2010 17:33:28 -0700 From: "David O'Brien" <obrien@FreeBSD.org> To: Bruce Evans <brde@optusnet.com.au> Cc: Juli Mallett <jmallett@FreeBSD.org>, svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r212374 - head/usr.bin/printf Message-ID: <20100917003328.GB13653@dragon.NUXI.org> In-Reply-To: <20100916212043.N724@delplex.bde.org> References: <201009091927.o89JReXm022426@svn.freebsd.org> <AANLkTi=1KXtmwVobbnk8vCkQKDN01RxWh8Q5ZZqzU0tq@mail.gmail.com> <20100916084442.GB21622@dragon.NUXI.org> <20100916212043.N724@delplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100917003328.GB13653>
