[SCM] Debian Live manual branch, master, updated. acfd9181a1617f2540343da8db7665d7d09279ff

Daniel Baumann daniel at debian.org
Mon Dec 8 12:05:10 UTC 2008


The following commit has been merged in the master branch:
commit acfd9181a1617f2540343da8db7665d7d09279ff
Author: Daniel Baumann <daniel at debian.org>
Date:   Mon Dec 8 13:05:00 2008 +0100

    Adding page about coding style.

diff --git a/xml/chapters/coding-style.xml b/xml/chapters/coding-style.xml
new file mode 100644
index 0000000..ee072fa
--- /dev/null
+++ b/xml/chapters/coding-style.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+    "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+  <!ENTITY % commondata SYSTEM "../entities/common.ent" > %commondata;
+]>
+<chapter id="coding-style">
+<title>Coding Style</title>
+
+<para>This chapter documents the coding style used in live-helper.</para>
+
+<sect1 id="compatibilty">
+<title>Compatibility</title>
+
+<itemizedlist>
+	<listitem>Don't use bashisms, e.g. no arrays.</listitem>
+	<listitem>Only use posix subset, e.g. use $(foo) rather than `foo`.</listitem>
+	<listitem>Do check your scripts with 'sh -n' and 'checkbasishm'.</listitem>
+</itemizedlist>
+</sect1>
+
+<sect1 id="indenting">
+<title>Indenting</title>
+
+<itemizedlist>
+	<listitem>Always use tabs and not spaces.</listitem>
+</itemizedlist>
+
+</sect1>
+
+<sect1 id="wrapping">
+<title>Wrapping</title>
+
+<itemizedlist>
+	<listitem>Generally, lines are 80 chars at maximum.</listitem>
+
+	<listitem>Use the linux like line breaks:
+
+	Bad:
+
+<screen>
+if foo; then
+	bar
+fi
+</screen>
+
+	Good:
+
+<screen>
+if foo
+then
+	bar
+fi
+</screen>
+
+	</listitem>
+
+	<listitem>Same for functions:
+
+	Bad:
+
+<screen>
+foo () {
+	bar
+}
+</screen>
+
+	Good:
+
+<screen>
+foo ()
+{
+	bar
+}
+</screen>
+
+	</listitem>
+</itemizedlist>
+
+</sect1>
+
+<sect1 id="variables">
+<title>Variables</title>
+
+<itemizedlist>
+	<listitem>Variables are always in capital letters.</listitem>
+	<listitem>Variables that used in config always start with LH_ prefix.</listitem>
+	<listitem>Internal, live-helper controlling variables start with _LH_ prefix.</listitem>
+	<listitem>Local variables start with __LH_ prefix.</listitem>
+	<listitem>Put curly brackets arround them, write ${FOO} not $FOO.</listitem>
+	<listitem>Always protect variables wrt/ potential whitespaces, write "${FOO}" not ${FOO}.</listitem>
+	<listitem>If multiple variables are used, quote the full expression:
+
+	Bad:
+
+<screen>
+if [ -f "${FOO}"/foo/"${BAR}"/bar ]
+then
+	foobar
+fi
+</screen>
+
+	Good:
+
+<screen>
+if [ -f "${FOO}/foo/${BAR}/bar" ]
+then
+	foobar
+fi
+</screen>
+
+	</listitem>
+</itemizedlist>
+
+</sect1>
+
+</chapter>
diff --git a/xml/index.xml b/xml/index.xml
index 96ca6b9..2a3d454 100644
--- a/xml/index.xml
+++ b/xml/index.xml
@@ -59,6 +59,7 @@ Document Format (PDF).
 <xi:include href="chapters/live-environment.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
 <xi:include href="chapters/faq.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
 <xi:include href="chapters/reporting-bugs.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
+<xi:include href="chapters/coding-style.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
 <xi:include href="chapters/resources.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
 
 <!-- Appendecis -->

-- 
Debian Live manual



More information about the debian-live-changes mailing list