aboutsummaryrefslogtreecommitdiff
path: root/bin/kenv
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2005-09-13 19:01:53 +0000
committerRobert Watson <rwatson@FreeBSD.org>2005-09-13 19:01:53 +0000
commitaf2b8e58cc3a71d54508844369785639988ce578 (patch)
tree67a8db17b042d207974e25b63a63f71870fbe455 /bin/kenv
parente88c48fefcdbceade1c3700548e5e67334b4779d (diff)
downloadsrc-af2b8e58cc3a71d54508844369785639988ce578.tar.gz
src-af2b8e58cc3a71d54508844369785639988ce578.zip
Add a "-q" quiet flag to kenv so that warnings can be suppressed.
MFC after: 1 week
Notes
Notes: svn path=/head/; revision=150101
Diffstat (limited to 'bin/kenv')
-rw-r--r--bin/kenv/kenv.19
-rw-r--r--bin/kenv/kenv.c20
2 files changed, 20 insertions, 9 deletions
diff --git a/bin/kenv/kenv.1 b/bin/kenv/kenv.1
index cb7b37703811..d9cdf8b564c5 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 ced383212b93..dc86ba8200a9 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);