diff --git a/en_US.ISO8859-1/articles/rc-scripting/article.xml b/en_US.ISO8859-1/articles/rc-scripting/article.xml index 0238769092..4fa3f56145 100644 --- a/en_US.ISO8859-1/articles/rc-scripting/article.xml +++ b/en_US.ISO8859-1/articles/rc-scripting/article.xml @@ -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\""