/[baselayout]/tags/baselayout-1.12.5/STYLE
Gentoo

Contents of /tags/baselayout-1.12.5/STYLE

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2240 - (hide annotations) (download)
Thu Sep 14 10:13:11 2006 UTC (12 years, 2 months ago) by uberlord
File size: 1924 byte(s)
tag 1.12.5
1 vapier 841 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 vapier 771
6     #############
7     # VARIABLES #
8     #############
9     - User Variables -
10     Variables must always be enclosed by {}
11     e.g. ${foo} ${bar}
12     - Internal Bash Variables -
13 vapier 841 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 or
19     a subshell, you do not need quotes, bash handles it
20     e.g. foo=${bar}
21     e.g. foo=$(uname -a)
22 vapier 771
23     #########
24     # TESTS #
25     #########
26     - Brackets -
27     Always use the [[ ... ]] form instead of [ ... ]
28 vapier 841 - Equality -
29     Always use == form instead of = when testing equality. Makes
30     for saner looking code (we all love C, don't lie).
31 vapier 771 - Quoting -
32 vapier 841 When dealing with strings, do not quote the LHS variable.
33     The [[ ... ]] handles spaces properly in variables. You
34     should always quote strings though.
35 vapier 771 e.g. [[ ${foo} = "bar" ]]
36 vapier 841 e.g. [[ "foo" != "bar" ]]
37     The RHS variable needs to be quoted to prevent against accidental
38     pattern matching (unless you want to match, of course).
39     e.g. [[ ${foo} = "${bar}" ]]
40     If foo=a-b and bar=a-* and ${bar} was not quoted, you would
41     get a match!
42 vapier 771
43     ###############
44     # CODE BLOCKS #
45     ###############
46 vapier 841 - Structure -
47 vapier 771 Use the more compact form
48     e.g. if ... ; then
49     e.g. while ... ; do
50     Do not use the older form
51     e.g. if ...
52     then
53     - Functions -
54     Use the more compact form
55     e.g. foo() {
56     Do not lead with 'function '
57     e.g. function foo() {
58    
59     ############
60     # COMMENTS #
61     ############
62     - General -
63     Try to include a comment block before sections
64     of code to explain what you're attempting

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20