summaryrefslogtreecommitdiffstats
path: root/sbin/sysctl
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-09-15 16:08:04 +0000
committerrwatson <rwatson@FreeBSD.org>2005-09-15 16:08:04 +0000
commitf62b675f2b1cc9f40f8e34edd56dbfb3d0d0d362 (patch)
tree418a511f8cd995377c695962a158dd8275fe5301 /sbin/sysctl
parent7584b6b2c3e7877240ac00a66ab3749b1adfdca8 (diff)
downloadFreeBSD-src-f62b675f2b1cc9f40f8e34edd56dbfb3d0d0d362.zip
FreeBSD-src-f62b675f2b1cc9f40f8e34edd56dbfb3d0d0d362.tar.gz
Add "-q" argument to sysctl(8), which suppresses a limited set of warnings/
errors generated. In particular, it suppresses "unknown oid" when attempting to get or set a sysctl not present in the kernel. MFC after: 1 week
Diffstat (limited to 'sbin/sysctl')
-rw-r--r--sbin/sysctl/sysctl.86
-rw-r--r--sbin/sysctl/sysctl.c16
2 files changed, 17 insertions, 5 deletions
diff --git a/sbin/sysctl/sysctl.8 b/sbin/sysctl/sysctl.8
index d6fde98..e7db649 100644
--- a/sbin/sysctl/sysctl.8
+++ b/sbin/sysctl/sysctl.8
@@ -40,7 +40,7 @@
.Ar name Ns Op = Ns Ar value
.Ar ...
.Nm
-.Op Fl bdehNnox
+.Op Fl bdehNnoqx
.Fl a
.Sh DESCRIPTION
The
@@ -111,6 +111,10 @@ use:
Show opaque variables (which are normally suppressed).
The format and length are printed, as well as a hex dump of the first
sixteen bytes of the value.
+.It Fl q
+Suppress some warnings generated by
+.Nm
+to standard error.
.It Fl X
Equivalent to
.Fl x a
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index ad35769..fd38cea 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -60,7 +60,8 @@ static const char rcsid[] =
#include <string.h>
#include <unistd.h>
-static int aflag, bflag, dflag, eflag, hflag, Nflag, nflag, oflag, xflag;
+static int aflag, bflag, dflag, eflag, hflag, Nflag, nflag, oflag;
+static int qflag, xflag;
static int oidfmt(int *, int, char *, u_int *);
static void parse(char *);
@@ -89,7 +90,7 @@ main(int argc, char **argv)
setbuf(stdout,0);
setbuf(stderr,0);
- while ((ch = getopt(argc, argv, "AabdehNnowxX")) != -1) {
+ while ((ch = getopt(argc, argv, "AabdehNnoqwxX")) != -1) {
switch (ch) {
case 'A':
/* compatibility */
@@ -119,6 +120,9 @@ main(int argc, char **argv)
case 'o':
oflag = 1;
break;
+ case 'q':
+ qflag = 1;
+ break;
case 'w':
/* compatibility */
/* ignored */
@@ -181,8 +185,12 @@ parse(char *string)
}
len = name2oid(bufp, mib);
- if (len < 0)
- errx(1, "unknown oid '%s'", bufp);
+ if (len < 0) {
+ if (qflag)
+ exit(1);
+ else
+ errx(1, "unknown oid '%s'", bufp);
+ }
if (oidfmt(mib, len, fmt, &kind))
err(1, "couldn't find format of oid '%s'", bufp);
OpenPOWER on IntegriCloud