Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Feb 2004 09:47:53 +0200
From:      Ruslan Ermilov <ru@freebsd.org>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        current@freebsd.org
Subject:   Re: usage() in install(1)
Message-ID:  <20040207074753.GD43602@FreeBSD.org.ua>
In-Reply-To: <2651.1076092124@critter.freebsd.dk>
References:  <20040206100605.GB27888@FreeBSD.org.ua> <2651.1076092124@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help

--+jhVVhN62yS6hEJ8
Content-Type: multipart/mixed; boundary="7LkOrbQMr4cezO2T"
Content-Disposition: inline


--7LkOrbQMr4cezO2T
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Feb 06, 2004 at 07:28:44PM +0100, Poul-Henning Kamp wrote:
> In message <20040206100605.GB27888@FreeBSD.org.ua>, Ruslan Ermilov writes:
>=20
> >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:
>=20
> 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".
>=20
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
>=20
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.
>=20
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,
--=20
Ruslan Ermilov
FreeBSD committer
ru@FreeBSD.org

--7LkOrbQMr4cezO2T
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=p
Content-Transfer-Encoding: quoted-printable

Index: xinstall.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 +=3D optind;
=20
 	/* some options make no sense when creating directories */
-	if (dostrip && dodir)
+	if (dostrip && dodir) {
+		warnx("-d and -s may not be specified together");
 		usage();
+	}
=20
 	/* must have at least two arguments, except when creating directories */
 	if (argc =3D=3D 0 || (argc =3D=3D 1 && !dodir))
@@ -215,8 +217,10 @@
 	}
=20
 	/* can't do file1 file2 directory/file */
-	if (argc !=3D 2)
+	if (argc !=3D 2) {
+		warnx("wrong number or types of arguments");
 		usage();
+	}
=20
 	if (!no_target) {
 		if (stat(*argv, &from_sb))

--7LkOrbQMr4cezO2T--

--+jhVVhN62yS6hEJ8
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFAJJgpUkv4P6juNwoRAop9AJ9LRiIbpjwtL4LGw8FeTIoFZwWlLwCeLZUV
tjIlx4HzHxyfbea6Z472Jno=
=HxLv
-----END PGP SIGNATURE-----

--+jhVVhN62yS6hEJ8--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040207074753.GD43602>