Module Name:    src
Committed By:   christos
Date:           Wed Aug  3 01:47:40 UTC 2011

Modified Files:
        src/sbin/sysctl: sysctl.8 sysctl.c

Log Message:
allow -q flag to work for reads.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sbin/sysctl/sysctl.8
cvs rdiff -u -r1.134 -r1.135 src/sbin/sysctl/sysctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/sysctl/sysctl.8
diff -u src/sbin/sysctl/sysctl.8:1.161 src/sbin/sysctl/sysctl.8:1.162
--- src/sbin/sysctl/sysctl.8:1.161	Wed Sep 30 00:30:50 2009
+++ src/sbin/sysctl/sysctl.8	Tue Aug  2 21:47:40 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sysctl.8,v 1.161 2009/09/30 04:30:50 elad Exp $
+.\"	$NetBSD: sysctl.8,v 1.162 2011/08/03 01:47:40 christos Exp $
 .\"
 .\" Copyright (c) 2004 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -54,7 +54,7 @@
 .\"
 .\"	@(#)sysctl.8	8.1 (Berkeley) 6/6/93
 .\"
-.Dd September 30, 2009
+.Dd August 2, 2011
 .Dt SYSCTL 8
 .Os
 .Sh NAME
@@ -62,7 +62,7 @@
 .Nd get or set kernel state
 .Sh SYNOPSIS
 .Nm sysctl
-.Op Fl AdeMn
+.Op Fl AdeMnq
 .Oo
 .Fl r |
 .Fl x
@@ -185,8 +185,11 @@
 set psize=`sysctl -n hw.pagesize`
 .Ed
 .It Fl q
-Used to indicate that nothing should be printed for writes unless an
+Used to indicate that nothing should be printed for reads or writes unless an
 error is detected.
+For reads, not finding a variable does not print an error, but exits with
+an error code.
+This is useful just for testing that a variable exists.
 .It Fl r
 Raw output form.
 Values printed are in their raw binary forms as retrieved directly

Index: src/sbin/sysctl/sysctl.c
diff -u src/sbin/sysctl/sysctl.c:1.134 src/sbin/sysctl/sysctl.c:1.135
--- src/sbin/sysctl/sysctl.c:1.134	Fri Apr 15 21:15:54 2011
+++ src/sbin/sysctl/sysctl.c	Tue Aug  2 21:47:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.c,v 1.134 2011/04/16 01:15:54 christos Exp $ */
+/*	$NetBSD: sysctl.c,v 1.135 2011/08/03 01:47:40 christos Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)sysctl.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.134 2011/04/16 01:15:54 christos Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.135 2011/08/03 01:47:40 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -321,8 +321,6 @@
 	argc -= optind;
 	argv += optind;
 
-	if (qflag && !wflag)
-		usage();
 	if (xflag && rflag)
 		usage();
 	/* if ((xflag || rflag) && wflag)
@@ -1540,7 +1538,7 @@
 		      "\t%s %s\n"
 		      "\t%s %s\n"
 		      "\t%s %s\n",
-		      progname, "[-dne] [-x[x]|-r] variable ...",
+		      progname, "[-dneq] [-x[x]|-r] variable ...",
 		      progname, "[-ne] [-q] -w variable=value ...",
 		      progname, "[-dne] -a",
 		      progname, "[-dne] -A",
@@ -1688,6 +1686,10 @@
 sysctlparseerror(u_int namelen, const char *pname)
 {
 
+	if (qflag) {
+		errs++;
+		return;
+	}
 	sysctlperror("%s level name '%s' in '%s' is invalid\n",
 		     lname[namelen], gsname, pname);
 }

Reply via email to