/[baselayout]/trunk/STYLE
Gentoo

Contents of /trunk/STYLE

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2547 - (show annotations) (download)
Thu Apr 5 11:18:42 2007 UTC (7 years, 7 months ago) by uberlord
File size: 1489 byte(s)
    Rewrite the core parts in C. We now provide librc so other programs can
    query runlevels, services and state without using bash. We also provide
    libeinfo so other programs can easily use our informational functions.

    As such, we have dropped the requirement of using bash as the init script
    shell. We now use /bin/sh and have strived to make the scripts as portable
    as possible. Shells that work are bash and dash. busybox works provided
    you disable s-s-d. If you have WIPE_TMP set to yes in conf.d/bootmisc you
    should disable find too.
    zsh and ksh do not work at this time.

    Networking support is currently being re-vamped also as it was heavily bash
    array based. As such, a new config format is available like so
    config_eth0="1.2.3.4/24 5.6.7.8/16"
    or like so
    config_eth0="'1.2.3.4 netmask 255.255.255.0' '5.6.7.8 netmask 255.255.0.0'"

    We will still support the old bash array format provided that /bin/sh IS
    a link it bash.

    ChangeLog for baselayout-1 can be found in our SVN repo.
1 This is the rc-scripts style manual. It governs the coding style
2 of rc-scripts. Everything here might as well have been spoken by
3 God. If you find any issues, please talk to base-system@gentoo.org
4 or #gentoo-base on irc.freenode.net.
5
6 #############
7 # VARIABLES #
8 #############
9 - User Variables -
10 Variables must always be enclosed by {}
11 e.g. ${foo} ${bar}
12 - Internal Shell Variables -
13 Do not use {} with internal variables unless appropriate
14 e.g. case $1 in
15 e.g. foo=$IFS
16 e.g. echo "blah${1}123"
17 - Assigning with Quotes -
18 When assigning to a variable from another variable, you should
19 not need quotes. However, you do when assigning from a subshell.
20 e.g. foo=${bar}
21 e.g. foo="$(uname -a)"
22
23 #########
24 # TESTS #
25 #########
26 - Brackets -
27 Always use the [ ... ] form instead of [[ ... ]] as the later only really
28 works in bash, and we should support as many shells as we can.
29 - Quoting -
30 When dealing with strings, you should quote both sides.
31
32 ###############
33 # CODE BLOCKS #
34 ###############
35 - Structure -
36 Use the more compact form
37 e.g. if ... ; then
38 e.g. while ... ; do
39 Do not use the older form
40 e.g. if ...
41 then
42 - Functions -
43 Use the more compact form
44 e.g. foo() {
45 Do not lead with 'function '
46 e.g. function foo() {
47
48 ############
49 # COMMENTS #
50 ############
51 - General -
52 Try to include a comment block before sections
53 of code to explain what you're attempting

  ViewVC Help
Powered by ViewVC 1.1.20