Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc Add checkyesnox function so we can test a configurable w...



details:   https://anonhg.NetBSD.org/src/rev/b318a0b9a8b6
branches:  trunk
changeset: 332428:b318a0b9a8b6
user:      roy <roy%NetBSD.org@localhost>
date:      Sun Sep 21 09:47:24 2014 +0000

description:
Add checkyesnox function so we can test a configurable without
being warned of its non-existance.

diffstat:

 etc/rc.subr |  27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)

diffs (54 lines):

diff -r 0658edfcf765 -r b318a0b9a8b6 etc/rc.subr
--- a/etc/rc.subr       Sun Sep 21 08:38:03 2014 +0000
+++ b/etc/rc.subr       Sun Sep 21 09:47:24 2014 +0000
@@ -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 @@
 
 #
 # 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 @@
                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".



Home | Main Index | Thread Index | Old Index