diff options
author | dteske <dteske@FreeBSD.org> | 2014-11-03 23:43:41 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2014-11-03 23:43:41 +0000 |
commit | 52436265329660279f7c8a2609ec9ffe8b65163b (patch) | |
tree | 8f7ddf3a372030d5bc3b4709dba1b45e542dae8b /usr.sbin/sysrc | |
parent | df2dc74ed1ab64739a5d752d87c2db42f10f96d6 (diff) | |
download | FreeBSD-src-52436265329660279f7c8a2609ec9ffe8b65163b.zip FreeBSD-src-52436265329660279f7c8a2609ec9ffe8b65163b.tar.gz |
Add key+=append syntax to sysrc(8).
Reviewed by: shurd
MFC after: 3 days
X-MFC-to: stable/10 stable/9
Diffstat (limited to 'usr.sbin/sysrc')
-rw-r--r-- | usr.sbin/sysrc/sysrc | 26 | ||||
-rw-r--r-- | usr.sbin/sysrc/sysrc.8 | 8 |
2 files changed, 27 insertions, 7 deletions
diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc index f37a496..8a1a863 100644 --- a/usr.sbin/sysrc/sysrc +++ b/usr.sbin/sysrc/sysrc @@ -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 diff --git a/usr.sbin/sysrc/sysrc.8 b/usr.sbin/sysrc/sysrc.8 index 28d8de6..fe6c4c4 100644 --- a/usr.sbin/sysrc/sysrc.8 +++ b/usr.sbin/sysrc/sysrc.8 @@ -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 |