usage() in install(1)
Ruslan Ermilov
ru at freebsd.org
Fri Feb 6 23:47:23 PST 2004
On Fri, Feb 06, 2004 at 07:28:44PM +0100, Poul-Henning Kamp wrote:
> In message <20040206100605.GB27888 at FreeBSD.org.ua>, Ruslan Ermilov writes:
>
> >Poul-Henning,
> >
> >I was very puzzled today trying to understand what is this line
> >number that install(1) is telling me about, especially that I've
> >just run it without any options, to see its usage.
> >
> >Please revert the part of the revision 1.62 where it was added.
> >I have the following reasons why it shouldn't have been done:
>
> I added it because the error messages from [x]install are singularly
> uninformative and at least the line numbers could serve as "guru
> meditation material".
>
There are four cases where it displays the usage:
1. When asked (``install -?'' or ``install'').
2. Incorrect option or missing option argument: getopt(3) takes
care of that.
3. Incompatible options are specified (-d and -s): the usage is
shown to let you decide what do you really want: -s or -d.
This is how most bin/ utils do that.
4. Wrong number or types of arguments: the usage is shown to
let you know the correct syntax.
> The correct solution of course is to replace the totally uninformative
> usage message
>
Come on now! How is it totally uninformative? It presents you
with the correct usage when you misuse it. You'd better watch
the cpio(1) usage. ;)
> which the program indiscriminatly spits out on any sort
> of trouble with intelligent informative error messages.
>
Only 3 and 4 lack the verbose reason, but this is how traditional
BSD programs behave. If it will make your life easier, feel free
to commit the attached patch.
Cheers,
--
Ruslan Ermilov
FreeBSD committer
ru at FreeBSD.org
-------------- next part --------------
Index: xinstall.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/xinstall/xinstall.c,v
retrieving revision 1.63
diff -u -r1.63 xinstall.c
--- xinstall.c 7 Feb 2004 07:22:11 -0000 1.63
+++ xinstall.c 7 Feb 2004 07:43:22 -0000
@@ -171,8 +171,10 @@
argv += optind;
/* some options make no sense when creating directories */
- if (dostrip && dodir)
+ if (dostrip && dodir) {
+ warnx("-d and -s may not be specified together");
usage();
+ }
/* must have at least two arguments, except when creating directories */
if (argc == 0 || (argc == 1 && !dodir))
@@ -215,8 +217,10 @@
}
/* can't do file1 file2 directory/file */
- if (argc != 2)
+ if (argc != 2) {
+ warnx("wrong number or types of arguments");
usage();
+ }
if (!no_target) {
if (stat(*argv, &from_sb))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20040207/5962be17/attachment.bin
More information about the freebsd-current
mailing list