summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2015-12-06 12:00:17 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2015-12-06 12:00:17 +0000
commitfa781fc376a73a5fd66733de6d5f4f7078af5b97 (patch)
treeb7447c66b23c25dc7404a82c2b0478e2436553db /bin
parente33812ae9ddd39e9387b8268ca681862956458ac (diff)
Use __progname instead of manually handling argv[0].
ok deraadt, mmcc, tedu
Diffstat (limited to 'bin')
-rw-r--r--bin/mt/mt.c16
-rw-r--r--bin/pax/options.c8
2 files changed, 9 insertions, 15 deletions
diff --git a/bin/mt/mt.c b/bin/mt/mt.c
index c9c8220ca19..eb08970629f 100644
--- a/bin/mt/mt.c
+++ b/bin/mt/mt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mt.c,v 1.36 2013/11/12 04:36:02 deraadt Exp $ */
+/* $OpenBSD: mt.c,v 1.37 2015/12/06 12:00:16 tobias Exp $ */
/* $NetBSD: mt.c,v 1.14.2.1 1996/05/27 15:12:11 mrg Exp $ */
/*
@@ -88,6 +88,8 @@ int _rmtmtioctop(int fd, struct mtop *com);
struct mtget *_rmtstatus(int fd);
void _rmtclose(void);
+extern char *__progname;
+
char *host = NULL; /* remote host (if any) */
int
@@ -133,7 +135,6 @@ _rmtclose(void)
#endif
}
-char *progname;
int eject = 0;
int
@@ -145,12 +146,7 @@ main(int argc, char *argv[])
char *p, *tape, *realtape, *opts;
size_t len;
- if ((progname = strrchr(argv[0], '/')))
- progname++;
- else
- progname = argv[0];
-
- if (strcmp(progname, "eject") == 0) {
+ if (strcmp(__progname, "eject") == 0) {
opts = "t";
eject = 1;
tape = NULL;
@@ -320,9 +316,9 @@ void
usage(void)
{
if (eject)
- (void)fprintf(stderr, "usage: %s [-t] device\n", progname);
+ (void)fprintf(stderr, "usage: %s [-t] device\n", __progname);
else
(void)fprintf(stderr,
- "usage: %s [-f device] command [count]\n", progname);
+ "usage: %s [-f device] command [count]\n", __progname);
exit(X_USAGE);
}
diff --git a/bin/pax/options.c b/bin/pax/options.c
index 2b15d395203..adb7f4a9265 100644
--- a/bin/pax/options.c
+++ b/bin/pax/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.91 2015/05/18 20:26:16 czarkoff Exp $ */
+/* $OpenBSD: options.c,v 1.92 2015/12/06 12:00:16 tobias Exp $ */
/* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */
/*-
@@ -184,14 +184,12 @@ char *chdname = NULL;
void
options(int argc, char **argv)
{
+ extern char *__progname;
/*
* Are we acting like pax, tar or cpio (based on argv[0])
*/
- if ((argv0 = strrchr(argv[0], '/')) != NULL)
- argv0++;
- else
- argv0 = argv[0];
+ argv0 = __progname;
if (strcmp(NM_TAR, argv0) == 0) {
tar_options(argc, argv);