Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Feb 2004 12:06:05 +0200
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        Poul-Henning Kamp <phk@FreeBSD.org>
Cc:        current@FreeBSD.org
Subject:   usage() in install(1)
Message-ID:  <20040206100605.GB27888@FreeBSD.org.ua>

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

--YD3LsXFS42OYHhNZ
Content-Type: multipart/mixed; boundary="ADZbWkCsHQ7r3kzd"
Content-Disposition: inline


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

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:

- It's mostly useless, because one should know that it refers to
  a source code line in xinstall.c (!), and have that source
  available.

- It's inspired by a lot of kernel programming, userland utils
  don't usually report line numbers of their sources, except
  for the assert() macro which is trying to catch programming
  (not usage) errors.  ;)

- There are only three cases where usage() is shown: traditional
  "bad option", traditional "incompatible options", traditional
  "missing or wrong number of arguments" (exactly like in cp(1)).

If you really need it, could you please keep it locally?  ;)

Or perhaps, that's a userland reply to the IP security option?
Then it should stay.  ;)


Cheers,
--=20
Ruslan Ermilov
FreeBSD committer
ru@FreeBSD.org

--ADZbWkCsHQ7r3kzd
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.62
diff -u -r1.62 xinstall.c
--- xinstall.c	11 Jul 2003 20:51:16 -0000	1.62
+++ xinstall.c	6 Feb 2004 09:40:23 -0000
@@ -97,7 +97,7 @@
 u_long	numeric_id(const char *, const char *);
 void	strip(const char *);
 int	trymmap(int);
-void	usage(int);
+void	usage(void);
=20
 int
 main(int argc, char *argv[])
@@ -165,18 +165,18 @@
 			break;
 		case '?':
 		default:
-			usage(__LINE__);
+			usage();
 		}
 	argc -=3D optind;
 	argv +=3D optind;
=20
 	/* some options make no sense when creating directories */
 	if (dostrip && dodir)
-		usage(__LINE__);
+		usage();
=20
 	/* must have at least two arguments, except when creating directories */
-	if (argc < 2 && !dodir)
-		usage(__LINE__);
+	if (argc =3D=3D 0 || (argc =3D=3D 1 && !dodir))
+		usage();
=20
 	/* need to make a temp copy so we can compare stripped version */
 	if (docompare && dostrip)
@@ -216,7 +216,7 @@
=20
 	/* can't do file1 file2 directory/file */
 	if (argc !=3D 2)
-		usage(__LINE__);
+		usage();
=20
 	if (!no_target) {
 		if (stat(*argv, &from_sb))
@@ -757,15 +757,14 @@
  *	print a usage message and die
  */
 void
-usage(int line)
+usage()
 {
-	(void)fprintf(stderr, "line %d\n"
+	(void)fprintf(stderr,
 "usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
 "               [-o owner] file1 file2\n"
 "       install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
 "               [-o owner] file1 ... fileN directory\n"
-"       install -d [-v] [-g group] [-m mode] [-o owner] directory ...\n",
-	line);
+"       install -d [-v] [-g group] [-m mode] [-o owner] directory ...\n");
 	exit(EX_USAGE);
 	/* NOTREACHED */
 }

--ADZbWkCsHQ7r3kzd--

--YD3LsXFS42OYHhNZ
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iD8DBQFAI2cNUkv4P6juNwoRAv7ZAJ9OWL7zh61Iu3zQA0EqJNHSSCJIfwCggUHP
9FNnTepA8cmWDat+tjzbUvc=
=oCZt
-----END PGP SIGNATURE-----

--YD3LsXFS42OYHhNZ--



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