Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Nov 2014 23:43:41 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r274068 - head/usr.sbin/sysrc
Message-ID:  <201411032343.sA3NhfgC098785@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Mon Nov  3 23:43:41 2014
New Revision: 274068
URL: https://svnweb.freebsd.org/changeset/base/274068

Log:
  Add key+=append syntax to sysrc(8).
  
  Reviewed by:	shurd
  MFC after:	3 days
  X-MFC-to:	stable/10 stable/9

Modified:
  head/usr.sbin/sysrc/sysrc
  head/usr.sbin/sysrc/sysrc.8

Modified: head/usr.sbin/sysrc/sysrc
==============================================================================
--- head/usr.sbin/sysrc/sysrc	Mon Nov  3 23:37:51 2014	(r274067)
+++ head/usr.sbin/sysrc/sysrc	Mon Nov  3 23:43:41 2014	(r274068)
@@ -40,7 +40,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
 #
 # Version information
 #
-SYSRC_VERSION="6.1 Jul-18,2014"
+SYSRC_VERSION="6.2 Nov-3,2014"
 
 #
 # Options
@@ -80,7 +80,7 @@ die()
 #
 usage()
 {
-	f_err "Usage: %s [OPTIONS] name[=value] ...\n" "$pgm"
+	f_err "Usage: %s [OPTIONS] name[[+]=value] ...\n" "$pgm"
 	f_err "Try \`%s --help' for more information.\n" "$pgm"
 	die
 }
@@ -94,7 +94,7 @@ help()
 	local optfmt="\t%-11s%s\n"
 	local envfmt="\t%-17s%s\n"
 
-	f_err "Usage: %s [OPTIONS] name[=value] ...\n" "$pgm"
+	f_err "Usage: %s [OPTIONS] name[[+]=value] ...\n" "$pgm"
 
 	f_err "OPTIONS:\n"
 	f_err "$optfmt" "-a" \
@@ -529,6 +529,11 @@ status=$SUCCESS
 while [ $# -gt 0 ]; do
 	NAME="${1%%=*}"
 
+	case "$NAME" in
+	*+) mode=APPEND NAME="${NAME%+}" ;;
+	 *) mode=ASSIGN
+	esac
+
 	[ "$DESCRIBE" ] && \
 		echo "$NAME: $( f_sysrc_desc "$NAME" )"
 
@@ -593,14 +598,25 @@ while [ $# -gt 0 ]; do
 		#
 		if [ ! "$SHOW_VALUE" ]; then
 			echo "$NAME"
-			f_sysrc_set "$NAME" "${1#*}"
+			case "$mode" in
+			APPEND)
+				before=$( f_sysrc_get "$NAME" )
+				f_sysrc_set "$NAME" "$before${1#*=}"
+				;;
+			*)
+				f_sysrc_set "$NAME" "${1#*=}"
+			esac
 		else
 			if [ "$SHOW_FILE" ]; then
 				before=$( f_sysrc_find "$NAME" )
 			else
 				before=$( f_sysrc_get "$NAME" )
 			fi
-			if f_sysrc_set "$NAME" "${1#*=}"; then
+			if case "$mode" in
+				APPEND) f_sysrc_set "$NAME" "$before${1#*=}" ;;
+				     *) f_sysrc_set "$NAME" "${1#*=}"
+				esac
+			then
 				if [ "$SHOW_FILE" ]; then
 					after=$( f_sysrc_find "$NAME" )
 				else

Modified: head/usr.sbin/sysrc/sysrc.8
==============================================================================
--- head/usr.sbin/sysrc/sysrc.8	Mon Nov  3 23:37:51 2014	(r274067)
+++ head/usr.sbin/sysrc/sysrc.8	Mon Nov  3 23:43:41 2014	(r274068)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd Jul 18, 2014
+.Dd November 3, 2014
 .Dt SYSRC 8
 .Os
 .Sh NAME
@@ -35,7 +35,7 @@
 .Op Fl cdDeFhinNqvx
 .Op Fl f Ar file
 .Op Fl j Ar jail | Fl R Ar dir
-.Ar name Ns Op = Ns Ar value
+.Ar name Ns Op Ns Oo + Oc Ns = Ns Ar value
 .Ar ...
 .Nm
 .Op Fl cdDeFhinNqvx
@@ -135,6 +135,10 @@ It shares the `-e' and `-n' options
 and also has the same
 .Ql name[=value]
 syntax for making queries/assignments.
+In addition
+.Pq unlike Xr sysctl 8 ,
+.Ql name+=value
+is supported for appending values.
 .Pp
 However, while
 .Xr sysctl 8



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