diff --git a/en_US.ISO8859-1/articles/rc-scripting/article.sgml b/en_US.ISO8859-1/articles/rc-scripting/article.sgml index 75f7926254..6452540464 100644 --- a/en_US.ISO8859-1/articles/rc-scripting/article.sgml +++ b/en_US.ISO8859-1/articles/rc-scripting/article.sgml @@ -240,13 +240,17 @@ run_rc_command "$1" (for the system) or /usr/local/sbin (for ports) and call it from a &man.sh.1; script in the appropriate rc.d directory. + - If you would like to know the details about why + + If you would like to learn the details of why rc.d scripts must be written in the &man.sh.1; language, see how /etc/rc - invokes them, then study the internals of - run_rc_script. - + invokes them by means of run_rc_script, + then study the implementation of + run_rc_script in + /etc/rc.subr. + @@ -284,6 +288,11 @@ run_rc_command "$1" set name before it calls &man.rc.subr.8; functions. + Now it is the right time to choose a unique name for + our script once and for all. We will use it in a number + of places while developing the script. For a start, let + us give the same name to the script file, too. + The current style of rc.d scripting is to enclose values assigned to variables @@ -331,6 +340,14 @@ run_rc_command "$1" The body of a sophisticated method can be implemented as a function. It is a good idea to make the function name meaningful. + + + It is strongly recommended to add the prefix + ${name} to the names of all functions + defined in our script so they never clash with the + functions from &man.rc.subr.8; or another common include + file. + @@ -463,10 +480,19 @@ run_rc_command "$1" This is a trivial example of how &man.rc.conf.5; variables can control an rc.d script. + + The names of all &man.rc.conf.5; variables used + exclusively by our script must + have the same prefix: ${name}. For + example: dummy_mode, + dummy_state_file, and so on. + + While it is possible to use a shorter name internally, - e.g., just msg, prepending a unique - prefix to global names will save us from possible + e.g., just msg, adding the unique prefix + ${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 @@ -980,7 +1006,7 @@ fi #!/bin/sh -# PROVIDE: mumble mumbled +# PROVIDE: mumbled oldmumble # REQUIRE: DAEMON cleanvar frotz # BEFORE: LOGIN # KEYWORD: nojail shutdown @@ -1019,27 +1045,9 @@ run_rc_command "$1" several conditions there, e.g., for compatibility reasons. - The best style is to use the same name for the - following entities: - - - - the script's file; - - - - its main PROVIDE: condition; - - - - its ${name}; - - - - the prefix of its &man.rc.conf.5; variables, - as well as of its private variables and functions. - - + In any case, the name of the main, or the only, + PROVIDE: condition should be the + same as ${name}.