usage() in install(1)
Ruslan Ermilov
ru at FreeBSD.org
Fri Feb 6 02:05:16 PST 2004
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,
--
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.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);
int
main(int argc, char *argv[])
@@ -165,18 +165,18 @@
break;
case '?':
default:
- usage(__LINE__);
+ usage();
}
argc -= optind;
argv += optind;
/* some options make no sense when creating directories */
if (dostrip && dodir)
- usage(__LINE__);
+ usage();
/* must have at least two arguments, except when creating directories */
- if (argc < 2 && !dodir)
- usage(__LINE__);
+ if (argc == 0 || (argc == 1 && !dodir))
+ usage();
/* need to make a temp copy so we can compare stripped version */
if (docompare && dostrip)
@@ -216,7 +216,7 @@
/* can't do file1 file2 directory/file */
if (argc != 2)
- usage(__LINE__);
+ usage();
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 */
}
-------------- 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/20040206/d326db5a/attachment.bin
More information about the freebsd-current
mailing list