From owner-svn-doc-all@FreeBSD.ORG Wed Oct 31 21:24:27 2012 Return-Path: Delivered-To: svn-doc-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 058D9F7A; Wed, 31 Oct 2012 21:24:27 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E1AD08FC18; Wed, 31 Oct 2012 21:24:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9VLOQ9V033949; Wed, 31 Oct 2012 21:24:26 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9VLOQGC033947; Wed, 31 Oct 2012 21:24:26 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201210312124.q9VLOQGC033947@svn.freebsd.org> From: Eitan Adler Date: Wed, 31 Oct 2012 21:24:26 +0000 (UTC) To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r39880 - head/en_US.ISO8859-1/articles/rc-scripting X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire doc trees \(except for " user" , " projects" , and " translations" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2012 21:24:27 -0000 Author: eadler Date: Wed Oct 31 21:24:26 2012 New Revision: 39880 URL: http://svn.freebsd.org/changeset/doc/39880 Log: Bring the RC article up to date. PR: docs/172692 Submitted by: crees Reviewed by: Michael Telahun Makonnen Approved by: bcr (mentor) Modified: head/en_US.ISO8859-1/articles/rc-scripting/article.xml Modified: head/en_US.ISO8859-1/articles/rc-scripting/article.xml ============================================================================== --- head/en_US.ISO8859-1/articles/rc-scripting/article.xml Wed Oct 31 12:55:35 2012 (r39879) +++ head/en_US.ISO8859-1/articles/rc-scripting/article.xml Wed Oct 31 21:24:26 2012 (r39880) @@ -400,8 +400,8 @@ start_cmd="${name}_start" stop_cmd=":" load_rc_config $name -eval "${rcvar}=\${${rcvar}:-'NO'}" -dummy_msg=${dummy_msg:-"Nothing started."} +: ${dummy_enable:=no} +: ${dummy_msg="Nothing started."} dummy_start() { @@ -448,7 +448,7 @@ run_rc_command "$1" system, you should add a default setting for the knob to /etc/defaults/rc.conf and document it in &man.rc.conf.5;. Otherwise it is your script that - should provide a default setting for the knob. A portable + should provide a default setting for the knob. The canonical approach to the latter case is shown in the example. @@ -479,7 +479,7 @@ run_rc_command "$1" The names of all &man.rc.conf.5; variables used exclusively by our script must - have the same prefix: ${name}. For + have the same prefix: ${name}_. For example: dummy_mode, dummy_state_file, and so on. @@ -487,19 +487,10 @@ run_rc_command "$1" While it is possible to use a shorter name internally, e.g., just msg, adding the unique prefix - ${name} to all global names introduced by + ${name}_ to all global names introduced by our script will save us from possible collisions with the &man.rc.subr.8; namespace. - As long as an &man.rc.conf.5; variable and its - internal equivalent are the same, we can use a more - compact expression to set the default value: - - : ${dummy_msg:="Nothing started."} - - The current style is to use the more verbose form - though. - As a rule, rc.d scripts of the base system need not provide defaults for their &man.rc.conf.5; variables because the defaults should @@ -512,7 +503,11 @@ run_rc_command "$1" Here we use dummy_msg to actually - control our script, i.e., to emit a variable message. + control our script, i.e., to emit a variable message. + Use of a shell function is overkill here, since it only + runs a single command; an equally valid alternative is: + + start_cmd="echo \"$dummy_msg\""