diff options
author | 2006-05-28 04:21:13 +0000 | |
---|---|---|
committer | 2006-05-28 04:21:13 +0000 | |
commit | 71725a7c0735f94a5e98a83d64e6a1caa7dd1f1b (patch) | |
tree | 86e241d273f3dabb200e7e66240dce8c03d6f56d | |
parent | Spacing in vfs_sysctl() (diff) | |
download | wireguard-openbsd-71725a7c0735f94a5e98a83d64e6a1caa7dd1f1b.tar.xz wireguard-openbsd-71725a7c0735f94a5e98a83d64e6a1caa7dd1f1b.zip |
o KNF
o Remove unnecessary casts
o Add __dead
o Remove /* NOTREACHED */
o Remove cases '?' and '-'
o Use more conventional getopt(3) syntax (argc -= optind;
argv += optind; right after while loop)
OK deraadt@
-rw-r--r-- | usr.bin/env/env.1 | 6 | ||||
-rw-r--r-- | usr.bin/env/env.c | 33 |
2 files changed, 18 insertions, 21 deletions
diff --git a/usr.bin/env/env.1 b/usr.bin/env/env.1 index 51574c8d447..0c2a0d50be7 100644 --- a/usr.bin/env/env.1 +++ b/usr.bin/env/env.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: env.1,v 1.11 2004/01/23 23:08:46 jmc Exp $ +.\" $OpenBSD: env.1,v 1.12 2006/05/28 04:21:13 ray Exp $ .\" Copyright (c) 1980, 1990 The Regents of the University of California. .\" All rights reserved. .\" @@ -107,10 +107,6 @@ could not be found. .Xr execvp 3 , .Xr environ 7 .Sh STANDARDS -The historic -.Fl -option has been deprecated but is still supported in this implementation. -.Pp The .Nm utility conforms to diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c index 445b50c20b4..db5d70f7f6c 100644 --- a/usr.bin/env/env.c +++ b/usr.bin/env/env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: env.c,v 1.10 2003/06/10 22:20:46 deraadt Exp $ */ +/* $OpenBSD: env.c,v 1.11 2006/05/28 04:21:13 ray Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -37,18 +37,18 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "@(#)env.c 8.3 (Berkeley) 4/2/94";*/ -static char rcsid[] = "$OpenBSD: env.c,v 1.10 2003/06/10 22:20:46 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: env.c,v 1.11 2006/05/28 04:21:13 ray Exp $"; #endif /* not lint */ #include <err.h> +#include <errno.h> +#include <locale.h> #include <stdio.h> -#include <string.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> -#include <locale.h> -#include <errno.h> -void usage(void); +__dead void usage(void); int main(int argc, char *argv[]) @@ -60,19 +60,19 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "i-")) != -1) - switch((char)ch) { - case '-': /* obsolete */ + while ((ch = getopt(argc, argv, "i")) != -1) + switch(ch) { case 'i': - if ((environ = (char **)calloc(1, sizeof(char *))) == NULL) + if ((environ = calloc(1, sizeof(char *))) == NULL) err(126, "calloc"); break; - case '?': default: usage(); } + argc -= optind; + argv += optind; - for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv) + for (; *argv && (p = strchr(*argv, '=')); ++argv) if (setenv(*argv, ++p, 1) == -1) { /* reuse 126, it matches the problem most */ exit(126); @@ -86,7 +86,6 @@ main(int argc, char *argv[]) */ execvp(*argv, argv); err((errno == ENOENT) ? 127 : 126, "%s", *argv); - /* NOTREACHED */ } for (ep = environ; *ep; ep++) @@ -98,7 +97,9 @@ main(int argc, char *argv[]) void usage(void) { - (void)fprintf(stderr, "usage: env [-i] [name=value ...] " - "[utility [argument ...]]\n"); - exit (1); + extern char *__progname; + + (void)fprintf(stderr, "usage: %s [-i] [name=value ...] " + "[utility [argument ...]]\n", __progname); + exit(1); } |