Minor enhancements, bug fixes, and man-page adjustments.
+ Make `sysrc -x foo' produce error status if foo is unset. NB: Reported by lme (everything else ``while I'm at it'') + Remove mention of SYSRC_VERBOSE from `sysrc --help' output. NB: False documentation leftover from an ancient precursor. + Make `sysrc -qc foo' work the same as `sysrc -ic foo' when foo is unset NB: For syntax convenience (my fingers know `-q' more than `-i'). + Update description of `-c' flag in help message/manual. + Update description of `-q' flag in help message/manual. + Make `sysrc -vc foo' work as documented in the manual NB: Show message stating whether foo is currently set. + Make `sysrc -vc foo=1' work as documented in the manual NB: Show message stating how value of foo would be changed (if at all). + Remove odd usage of parentheses in `-R dir' section of manual. + Clarify syntax section of manual w/respect to sysctl(8) similarities. + Add new/missing people to the `THANKS TO' section of the manual. Reported by: lme MFC after: 3 days X-MFC-to: stable/10, stable/9, ports
This commit is contained in:
parent
89f8d00f2c
commit
dd349dd9aa
@ -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
|
||||
|
@ -58,11 +58,14 @@ Dump a list of all non-default configuration variables.
|
||||
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 names.
|
||||
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 exit.
|
||||
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 Mt 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.
|
||||
|
Loading…
Reference in New Issue
Block a user