From owner-svn-src-head@FreeBSD.ORG Fri Jul 18 22:44:16 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6160F99; Fri, 18 Jul 2014 22:44:16 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DE9727C0; Fri, 18 Jul 2014 22:44:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6IMiGOe037495; Fri, 18 Jul 2014 22:44:16 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6IMiF0W037493; Fri, 18 Jul 2014 22:44:15 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201407182244.s6IMiF0W037493@svn.freebsd.org> From: Devin Teske Date: Fri, 18 Jul 2014 22:44:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268860 - head/usr.sbin/sysrc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jul 2014 22:44:16 -0000 Author: dteske Date: Fri Jul 18 22:44:15 2014 New Revision: 268860 URL: http://svnweb.freebsd.org/changeset/base/268860 Log: 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 Modified: head/usr.sbin/sysrc/sysrc head/usr.sbin/sysrc/sysrc.8 Modified: head/usr.sbin/sysrc/sysrc ============================================================================== --- head/usr.sbin/sysrc/sysrc Fri Jul 18 22:34:01 2014 (r268859) +++ head/usr.sbin/sysrc/sysrc Fri Jul 18 22:44:15 2014 (r268860) @@ -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: head/usr.sbin/sysrc/sysrc.8 ============================================================================== --- head/usr.sbin/sysrc/sysrc.8 Fri Jul 18 22:34:01 2014 (r268859) +++ head/usr.sbin/sysrc/sysrc.8 Fri Jul 18 22:44:15 2014 (r268860) @@ -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 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.