diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-09-13 19:01:53 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-09-13 19:01:53 +0000 |
commit | 3b28b9c8194d24580bd1bf543ea157cec83826d8 (patch) | |
tree | 67a8db17b042d207974e25b63a63f71870fbe455 /bin/kenv/kenv.c | |
parent | 4ddf28af8747dee2cb90077fa72d7290765570d9 (diff) | |
download | FreeBSD-src-3b28b9c8194d24580bd1bf543ea157cec83826d8.zip FreeBSD-src-3b28b9c8194d24580bd1bf543ea157cec83826d8.tar.gz |
Add a "-q" quiet flag to kenv so that warnings can be suppressed.
MFC after: 1 week
Diffstat (limited to 'bin/kenv/kenv.c')
-rw-r--r-- | bin/kenv/kenv.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/bin/kenv/kenv.c b/bin/kenv/kenv.c index ced3832..dc86ba8 100644 --- a/bin/kenv/kenv.c +++ b/bin/kenv/kenv.c @@ -42,15 +42,16 @@ static int ksetenv(char *, char *); static int kunsetenv(char *); static int hflag = 0; +static int qflag = 0; static int uflag = 0; static void usage(void) { (void)fprintf(stderr, "%s\n%s\n%s\n", - "usage: kenv [-h]", - " kenv variable[=value]", - " kenv -u variable"); + "usage: kenv [-hq]", + " kenv [-q] variable[=value]", + " kenv [-q] -u variable"); exit(1); } @@ -63,11 +64,14 @@ main(int argc, char **argv) error = 0; val = NULL; env = NULL; - while ((ch = getopt(argc, argv, "hu")) != -1) { + while ((ch = getopt(argc, argv, "hqu")) != -1) { switch (ch) { case 'h': hflag++; break; + case 'q': + qflag++; + break; case 'u': uflag++; break; @@ -93,21 +97,21 @@ main(int argc, char **argv) usage(); if (env == NULL) { error = kdumpenv(); - if (error) + if (error && !qflag) warn("kdumpenv"); } else if (val == NULL) { if (uflag) { error = kunsetenv(env); - if (error) + if (error && !qflag) warnx("unable to unset %s", env); } else { error = kgetenv(env); - if (error) + if (error && !qflag) warnx("unable to get %s", env); } } else { error = ksetenv(env, val); - if (error) + if (error && !qflag) warnx("unable to set %s to %s", env, val); } return (error); |