Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Sep 2014 22:54:11 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r272191 - stable/10/usr.sbin/sysrc
Message-ID:  <201409262254.s8QMsBnx039667@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Fri Sep 26 22:54:10 2014
New Revision: 272191
URL: http://svnweb.freebsd.org/changeset/base/272191

Log:
  MFC revisions 268860, 268863:
  r268860: Minor enhancements, bug fixes, and man-page adjustments.
  r268863: Bump .Dd in manual
  
  Reported by:	lme
  Approved by:	re (gjb)

Modified:
  stable/10/usr.sbin/sysrc/sysrc
  stable/10/usr.sbin/sysrc/sysrc.8
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/sysrc/sysrc
==============================================================================
--- stable/10/usr.sbin/sysrc/sysrc	Fri Sep 26 22:21:02 2014	(r272190)
+++ stable/10/usr.sbin/sysrc/sysrc	Fri Sep 26 22:54:10 2014	(r272191)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #-
-# Copyright (c) 2010-2013 Devin Teske
+# Copyright (c) 2010-2014 Devin Teske
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
 #
 # Version information
 #
-SYSRC_VERSION="6.0 Nov-07,2013"
+SYSRC_VERSION="6.1 Jul-18,2014"
 
 #
 # Options
@@ -102,7 +102,7 @@ help()
 	f_err "$optfmt" "-A" \
 	      "Dump a list of all configuration variables (incl. defaults)."
 	f_err "$optfmt" "-c" \
-	      "Check. Return success if no changes needed, else error."
+	      "Check. Return success if set or no changes, else error."
 	f_err "$optfmt" "-d" \
 	      "Print a description of the given variable."
 	f_err "$optfmt" "-D" \
@@ -134,7 +134,7 @@ help()
 	f_err "$optfmt" "-N" \
 	      "Show only variable names, not their values."
 	f_err "$optfmt" "-q" \
-	      "Quiet. Ignore previous \`-v' and/or SYSRC_VERBOSE."
+	      "Quiet. Disable verbose and hide certain errors."
 	f_err "$optfmt" "-R dir" \
 	      "Operate within the root directory \`dir' rather than \`/'."
 	f_err "$optfmt" "-v" \
@@ -152,8 +152,6 @@ help()
 	      "Override default rc_conf_files (even if set to NULL)."
 	f_err "$envfmt" "RC_DEFAULTS" \
 	      "Location of \`/etc/defaults/rc.conf' file."
-	f_err "$envfmt" "SYSRC_VERBOSE" \
-	      "Default verbosity. Set to non-NULL to enable."
 
 	die
 }
@@ -527,7 +525,7 @@ fi
 #
 # Process command-line arguments
 #
-costatus=$SUCCESS
+status=$SUCCESS
 while [ $# -gt 0 ]; do
 	NAME="${1%%=*}"
 
@@ -558,7 +556,7 @@ while [ $# -gt 0 ]; do
 		# desire to set some value
 		#
 		if [ "$DELETE" ]; then
-			f_sysrc_delete "$NAME"
+			f_sysrc_delete "$NAME" || status=$FAILURE
 			shift 1
 			continue
 		fi
@@ -568,10 +566,23 @@ while [ $# -gt 0 ]; do
 		#
 		if [ "$CHECK_ONLY" ]; then
 			if ! IGNORED=$( f_sysrc_get "$NAME?" ); then
-				costatus=$FAILURE
-			else
-				value=$( f_sysrc_get "$NAME" )
-				[ "$value" = "${1#*=}" ] || costatus=$FAILURE
+				status=$FAILURE
+				[ "$SYSRC_VERBOSE" ] &&
+					echo "$NAME: not currently set"
+				shift 1
+				continue
+			fi
+			value=$( f_sysrc_get "$NAME" )
+			if [ "$value" != "${1#*=}" ]; then
+				status=$FAILURE
+				if [ "$SYSRC_VERBOSE" ]; then
+					echo -n "$( f_sysrc_find "$NAME" ): "
+					echo -n "$NAME: would change from "
+					echo "\`$value' to \`${1#*=}'"
+				fi
+			elif [ "$SYSRC_VERBOSE" ]; then
+				echo -n "$( f_sysrc_find "$NAME" ): "
+				echo "$NAME: already set to \`$value'"
 			fi
 			shift 1
 			continue
@@ -604,10 +615,10 @@ while [ $# -gt 0 ]; do
 		;;
 	*)
 		if ! IGNORED=$( f_sysrc_get "$NAME?" ); then
-			[ "$IGNORE_UNKNOWNS" ] ||
+			[ "$IGNORE_UNKNOWNS" -o "$QUIET" ] ||
 				echo "$pgm: unknown variable '$NAME'"
 			shift 1
-			costatus=$FAILURE
+			status=$FAILURE
 			continue
 		fi
 
@@ -631,7 +642,7 @@ while [ $# -gt 0 ]; do
 		# If `-x' or `-X' is passed, delete the variable
 		#
 		if [ "$DELETE" ]; then
-			f_sysrc_delete "$NAME"
+			f_sysrc_delete "$NAME" || status=$FAILURE
 			shift 1
 			continue
 		fi
@@ -667,7 +678,7 @@ while [ $# -gt 0 ]; do
 	shift 1
 done
 
-[ ! "$CHECK_ONLY" ] || exit $costatus
+exit $status # $SUCCESS unless error occurred with either `-c' or `-x'
 
 ################################################################################
 # END

Modified: stable/10/usr.sbin/sysrc/sysrc.8
==============================================================================
--- stable/10/usr.sbin/sysrc/sysrc.8	Fri Sep 26 22:21:02 2014	(r272190)
+++ stable/10/usr.sbin/sysrc/sysrc.8	Fri Sep 26 22:54:10 2014	(r272191)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2011-2013 Devin Teske
+.\" Copyright (c) 2011-2014 Devin Teske
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd Nov 20, 2013
+.Dd Jul 18, 2014
 .Dt SYSRC 8
 .Os
 .Sh NAME
@@ -58,11 +58,14 @@ Dump a list of all non-default configura
 Dump a list of all configuration variables
 .Pq incl. defaults .
 .It Fl c
-Check if the value will change when assigning a new value.
+Check only.
+For querying, return success if all requested variables are set
+.Pq even if NULL ,
+otherwise return error status.
+For assignments, return success if no changes are required, otherwise failure.
 If verbose
 .Pq see Dq Fl v
-prints a message stating whether a change would occur.
-Exits with success if no change is necessary, else returns error status.
+prints a message stating whether variables are set and/or changes are required.
 .It Fl d
 Print a description of the given variable.
 .It Fl D
@@ -108,14 +111,12 @@ Show only variable values, not their nam
 Show only variable names, not their values.
 .It Fl q
 Quiet.
-Ignore previous occurrences of
-.Fl v
-flag.
+Disable verbose and hide certain errors.
 .It Fl R Ar dir
 Operate within the root directory
-.Pq Sq Ar dir
+.Sq Ar dir
 rather than
-.Pq Sq / .
+.Sq / .
 .It Fl v
 Verbose.
 Print the pathname of the specific
@@ -127,13 +128,13 @@ Print version information to stdout and 
 Remove variable(s) from specified file(s).
 .El
 .Pp
-This utility works similar to
+This utility has a similar syntax to
 .Xr sysctl 8 .
 It shares the `-e' and `-n' options
 .Pq detailed above
 and also has the same
 .Ql name[=value]
-syntax for querying/setting configuration options.
+syntax for making queries/assignments.
 .Pp
 However, while
 .Xr sysctl 8
@@ -304,5 +305,5 @@ utility first appeared in
 .An Devin Teske Aq dteske@FreeBSD.org
 .Sh THANKS TO
 Brandon Gooch, Garrett Cooper, Julian Elischer, Pawel Jakub Dawidek,
-Cyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, and Jilles Tjoelker
-for suggestions and help.
+Cyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, Jilles Tjoelker,
+Allan Jude, and Lars Engels for suggestions, help, and testing.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409262254.s8QMsBnx039667>