Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/chown - use {g,s}etprogname()
details: https://anonhg.NetBSD.org/src/rev/e5833974f0ca
branches: trunk
changeset: 782250:e5833974f0ca
user: christos <christos%NetBSD.org@localhost>
date: Tue Oct 23 17:55:46 2012 +0000
description:
- use {g,s}etprogname()
- fix usage
diffstat:
sbin/chown/chown.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diffs (52 lines):
diff -r ec2fe7476af0 -r e5833974f0ca sbin/chown/chown.c
--- a/sbin/chown/chown.c Tue Oct 23 17:30:59 2012 +0000
+++ b/sbin/chown/chown.c Tue Oct 23 17:55:46 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chown.c,v 1.6 2012/10/22 18:02:26 christos Exp $ */
+/* $NetBSD: chown.c,v 1.7 2012/10/23 17:55:46 christos Exp $ */
/*
* Copyright (c) 1988, 1993, 1994, 2003
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)chown.c 8.8 (Berkeley) 4/4/94";
#else
-__RCSID("$NetBSD: chown.c,v 1.6 2012/10/22 18:02:26 christos Exp $");
+__RCSID("$NetBSD: chown.c,v 1.7 2012/10/23 17:55:46 christos Exp $");
#endif
#endif /* not lint */
@@ -68,7 +68,7 @@
static uid_t uid;
static gid_t gid;
static int ischown;
-static char *myname;
+static const char *myname;
struct option chown_longopts[] = {
{ "reference", required_argument, 0,
@@ -86,9 +86,11 @@
char *cp, *reference;
int (*change_owner)(const char *, uid_t, gid_t);
+ setprogname(*argv);
+
(void)setlocale(LC_ALL, "");
- myname = (cp = strrchr(*argv, '/')) ? cp + 1 : *argv;
+ myname = getprogname();
ischown = (myname[2] == 'o');
reference = NULL;
@@ -292,7 +294,9 @@
{
(void)fprintf(stderr,
- "usage: %s [-R [-H | -L | -P]] [-fhv] %s file ...\n",
- myname, ischown ? "[owner][:group]" : "group");
+ "Usage: %s [-R [-H | -L | -P]] [-fhv] %s file ...\n"
+ "\t%s [-R [-H | -L | -P]] [-fhv] --reference=rfile file ...\n",
+ myname, ischown ? "owner:group|owner|:group" : "group",
+ myname);
exit(EXIT_FAILURE);
}
Home |
Main Index |
Thread Index |
Old Index