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 | |
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')
-rw-r--r-- | bin/kenv/kenv.1 | 9 | ||||
-rw-r--r-- | bin/kenv/kenv.c | 20 |
2 files changed, 20 insertions, 9 deletions
diff --git a/bin/kenv/kenv.1 b/bin/kenv/kenv.1 index cb7b377..d9cdf8b 100644 --- a/bin/kenv/kenv.1 +++ b/bin/kenv/kenv.1 @@ -32,10 +32,12 @@ .Nd dump or modify the kernel environment .Sh SYNOPSIS .Nm -.Op Fl h +.Op Fl hq .Nm +.Op Fl q .Ar variable Ns Op = Ns Ar value .Nm +.Op Fl q .Fl u .Ar variable .Sh DESCRIPTION @@ -60,6 +62,11 @@ If the environment variable is followed by an optional .Ar value , .Nm will set the environment variable to this value. +.Pp +If the +.Fl q +option is set, warnings normally printed as a result of being unable to +perform the requested operation will be suppressed. .Sh SEE ALSO .Xr kenv 2 , .Xr loader 8 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); |