Module Name:    src
Committed By:   christos
Date:           Tue Oct 23 17:55:46 UTC 2012

Modified Files:
        src/sbin/chown: chown.c

Log Message:
- use {g,s}etprogname()
- fix usage


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/chown/chown.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/chown/chown.c
diff -u src/sbin/chown/chown.c:1.6 src/sbin/chown/chown.c:1.7
--- src/sbin/chown/chown.c:1.6	Mon Oct 22 14:02:26 2012
+++ src/sbin/chown/chown.c	Tue Oct 23 13:55:46 2012
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #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 @@ __dead static void	usage(void);
 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 @@ main(int argc, char **argv)
 	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 @@ usage(void)
 {
 
 	(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);
 }

Reply via email to