Module Name: src
Committed By: roy
Date: Sun Sep 21 09:47:24 UTC 2014
Modified Files:
src/etc: rc.subr
Log Message:
Add checkyesnox function so we can test a configurable without
being warned of its non-existance.
To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/etc/rc.subr
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/etc/rc.subr
diff -u src/etc/rc.subr:1.94 src/etc/rc.subr:1.95
--- src/etc/rc.subr:1.94 Sun Jul 27 07:46:46 2014
+++ src/etc/rc.subr Sun Sep 21 09:47:24 2014
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.94 2014/07/27 07:46:46 apb Exp $
+# $NetBSD: rc.subr,v 1.95 2014/09/21 09:47:24 roy Exp $
#
# Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -42,10 +42,10 @@ nl='
#
# checkyesno var
-# Test $1 variable, and warn if not set to YES or NO.
-# Return 0 if it's "yes" (et al), nonzero otherwise.
+# Test $1 variable.
+# Return 0 if it's "yes" (et al), 1 if it's "no" (et al), 2 otherwise.
#
-checkyesno()
+checkyesnox()
{
eval _value=\$${1}
case $_value in
@@ -60,13 +60,28 @@ checkyesno()
return 1
;;
*)
- warn "\$${1} is not set properly - see ${rcvar_manpage}."
- return 1
+ return 2
;;
esac
}
#
+# checkyesno var
+# Test $1 variable, and warn if not set to YES or NO.
+# Return 0 if it's "yes" (et al), nonzero otherwise.
+#
+checkyesno()
+{
+ local var
+
+ checkyesnox $1
+ var=$?
+ [ $var = 0 -o $var = 1 ] && return $var
+ warn "\$${1} is not set properly - see ${rcvar_manpage}."
+ return 1
+}
+
+#
# yesno_to_truefalse var
# Convert the value of a variable from any of the values
# understood by checkyesno() to "true" or "false".