/usr/share/doc/live-manual/html/coding-style.en.html is in live-manual-html 1:3.0~a9-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
coding-style -
Debian Live Manual
</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="dc.title" content="Debian Live Manual" />
<meta name="dc.author" content="Debian Live Project <debian-live@lists.debian.org>" />
<meta name="dc.publisher" content="Debian Live Project <debian-live@lists.debian.org>" />
<meta name="dc.date" content="2011-12-04" />
<meta name="dc.rights" content="Copyright (C) 2006-2011 Debian Live Project;<br> License: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br><br>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.<br><br>You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. <br><br>The complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL-3 file." />
<meta name="generator" content="SiSU 3.1.9 of 2011w51/1 (2011-12-19) (n*x and Ruby!)" />
<link rel="generator" href="http://www.sisudoc.org/" />
<link rel="shortcut icon" href="../_sisu/image/rb7.ico" />
<link rel="stylesheet" href="../_sisu/css/html.css" type="text/css" />
</head>
<body bgcolor="#ffffff" text="#000000" link="#003090" lang="en" xml:lang="en">
<a name="top" id="top"></a>
<a name="up" id="up"></a>
<a name="start" id="start"></a><table summary="segment navigation band with banner" bgcolor="#ffffff" width="100%"><tr>
<td width="20%" align="left">
<table summary="band" border="0" cellpadding="3" cellspacing="0"><tr><td align="left" bgcolor="#ffffff"><a href="http://live.debian.net/" target="_top"><img border="0" src="../_sisu/image/debian_home.png" alt="Debian -->" /></a></td></tr>
</table>
</td>
<td width="75%" align="center">
<table summary="segment navigation available documents types: toc,doc,pdf,concordance" border="0" cellpadding="3" cellspacing="0">
<tr>
<td align="center" bgcolor="#ffffff">
<td align="center" bgcolor="#ffffff">
<a href="sisu_manifest.en.html" target="_top" >
<font face="verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman" size="2">
[ document manifest ]
</font>
</a>
</td>
</tr></table>
</td>
<td width="5%" align="right">
<table summary="segment navigation pre/next" border="0" cellpadding="3" cellspacing="0">
<tr>
<td align="center" bgcolor="#ffffff">
<a href="bugs.en.html" target="_top" >
<img border="0" width="22" height="22" src="../_sisu/image_sys/arrow_prev_red.png" alt="<< previous" />
</a>
</td>
<td align="center" bgcolor="#ffffff">
<a href="toc.en.html" target="_top" >
<img border="0" width="22" height="22" src="../_sisu/image_sys/arrow_up_red.png" alt="TOC" />
</a>
</td>
<td align="center" bgcolor="#ffffff">
<a href="procedures.en.html" target="_top" >
<img border="0" width="22" height="22" src="../_sisu/image_sys/arrow_next_red.png" alt="next >>" />
</a>
</td>
<td>
</td></tr>
</table>
</td></tr>
</table>
<table summary="segment hidden control pre and next" width="100%" border="0" cellpadding="0" bgcolor=#eeeeee align="center">
<tr><td align="left">
<a href="bugs.en.html" target="_top" >
<img border="0" width="100%" height="20" src="../_sisu/image_sys/dot_white.png" alt="<" />
</a>
</td>
<td align="center">
<a href="toc.en.html" target="_top" >
<img border="0" width="100%" height="20" src="../_sisu/image_sys/dot_white.png" alt="^" />
</a>
</td>
<td align="right">
<a href="procedures.en.html" target="_top" >
<img border="0" width="100%" height="20" src="../_sisu/image_sys/dot_white.png" alt=">" />
</a>
</td></tr>
</table><div class="content">
<h1 class="tiny">
Debian Live Manual
</h1>
</div><div class="content">
<h2 class="tiny">
Project
</h2>
</div><div class="content"><div class="substance">
<label class="ocn"><a name="624" href="#624" class="lnkocn">624</a></label>
<h1 class="norm" id="o624"><a name="624"></a>
14. Coding Style
</h1>
</div><div class="substance">
<label class="ocn"><a name="625" href="#625" class="lnkocn">625</a></label>
<p class="i0" id="o625">
This chapter documents the coding style used in <i>live-boot</i> and others.
</p>
</div><div class="substance">
<label class="ocn"><a name="626" href="#626" class="lnkocn">626</a></label>
<p class="bold" id="o626"><a name="626"></a> <a name="h14.1" id="h14.1"></a>
<a name="14.1" ></a><a name="h14.1" ></a>14.1 Compatibility
</p>
</div><div class="substance">
<label class="ocn"><a name="627" href="#627" class="lnkocn">627</a></label>
<li class="bullet" id="o627">
Don't use syntax or semantics that are unique to the Bash shell. For example, the use of array constructs.
</li>
</div><div class="substance">
<label class="ocn"><a name="628" href="#628" class="lnkocn">628</a></label>
<li class="bullet" id="o628">
Only use the POSIX subset - for example, use $(foo) over `foo`.
</li>
</div><div class="substance">
<label class="ocn"><a name="629" href="#629" class="lnkocn">629</a></label>
<li class="bullet" id="o629">
You can check your scripts with 'sh -n' and 'checkbashisms'.
</li>
</div><div class="substance">
<label class="ocn"><a name="630" href="#630" class="lnkocn">630</a></label>
<p class="bold" id="o630"><a name="630"></a> <a name="h14.2" id="h14.2"></a>
<a name="14.2" ></a><a name="h14.2" ></a>14.2 Indenting
</p>
</div><div class="substance">
<label class="ocn"><a name="631" href="#631" class="lnkocn">631</a></label>
<li class="bullet" id="o631">
Always use tabs over spaces.
</li>
</div><div class="substance">
<label class="ocn"><a name="632" href="#632" class="lnkocn">632</a></label>
<p class="bold" id="o632"><a name="632"></a> <a name="h14.3" id="h14.3"></a>
<a name="14.3" ></a><a name="h14.3" ></a>14.3 Wrapping
</p>
</div><div class="substance">
<label class="ocn"><a name="633" href="#633" class="lnkocn">633</a></label>
<li class="bullet" id="o633">
Generally, lines are 80 chars at maximum.
</li>
</div><div class="substance">
<label class="ocn"><a name="634" href="#634" class="lnkocn">634</a></label>
<li class="bullet" id="o634">
Use the "Linux style" of line breaks:
</li>
</div><div class="substance">
<label class="ocn"><a name="635" href="#635" class="lnkocn">635</a></label>
<p class="i0" id="o635">
Bad:
</p>
</div><div class="substance">
<label class="ocn"><a name="636" href="#636" class="lnkocn">636</a></label>
<p class="code" id="o636">
if foo; then<br />
bar<br />
fi<br /><br />
</p>
</div><div class="substance">
<label class="ocn"><a name="637" href="#637" class="lnkocn">637</a></label>
<p class="i0" id="o637">
Good:
</p>
</div><div class="substance">
<label class="ocn"><a name="638" href="#638" class="lnkocn">638</a></label>
<p class="code" id="o638">
if foo<br />
then<br />
bar<br />
fi<br /><br />
</p>
</div><div class="substance">
<label class="ocn"><a name="639" href="#639" class="lnkocn">639</a></label>
<li class="bullet" id="o639">
The same holds for functions:
</li>
</div><div class="substance">
<label class="ocn"><a name="640" href="#640" class="lnkocn">640</a></label>
<p class="i0" id="o640">
Bad:
</p>
</div><div class="substance">
<label class="ocn"><a name="641" href="#641" class="lnkocn">641</a></label>
<p class="code" id="o641">
foo () {<br />
bar<br />
}<br /><br />
</p>
</div><div class="substance">
<label class="ocn"><a name="642" href="#642" class="lnkocn">642</a></label>
<p class="i0" id="o642">
Good:
</p>
</div><div class="substance">
<label class="ocn"><a name="643" href="#643" class="lnkocn">643</a></label>
<p class="code" id="o643">
foo ()<br />
{<br />
bar<br />
}<br /><br />
</p>
</div><div class="substance">
<label class="ocn"><a name="644" href="#644" class="lnkocn">644</a></label>
<p class="bold" id="o644"><a name="644"></a> <a name="h14.4" id="h14.4"></a>
<a name="14.4" ></a><a name="h14.4" ></a>14.4 Variables
</p>
</div><div class="substance">
<label class="ocn"><a name="645" href="#645" class="lnkocn">645</a></label>
<li class="bullet" id="o645">
Variables are always in capital letters.
</li>
</div><div class="substance">
<label class="ocn"><a name="646" href="#646" class="lnkocn">646</a></label>
<li class="bullet" id="o646">
Variables that used in <tt>lb config</tt> always start with <tt>LB_</tt> prefix.
</li>
</div><div class="substance">
<label class="ocn"><a name="647" href="#647" class="lnkocn">647</a></label>
<li class="bullet" id="o647">
Internal temporary variables in <i>live-build</i> should start with the <tt>_LB_</tt> prefix.
</li>
</div><div class="substance">
<label class="ocn"><a name="648" href="#648" class="lnkocn">648</a></label>
<li class="bullet" id="o648">
Local variables start with <i>live-build</i> <tt>__LB_</tt> prefix.
</li>
</div><div class="substance">
<label class="ocn"><a name="649" href="#649" class="lnkocn">649</a></label>
<li class="bullet" id="o649">
Variables in connection to a boot parameter in <i>live-config</i> start with <tt>LIVE_</tt>.
</li>
</div><div class="substance">
<label class="ocn"><a name="650" href="#650" class="lnkocn">650</a></label>
<li class="bullet" id="o650">
All other variables in <i>live-config</i> start with <tt>_</tt> prefix.
</li>
</div><div class="substance">
<label class="ocn"><a name="651" href="#651" class="lnkocn">651</a></label>
<li class="bullet" id="o651">
Use braces around variables; e.g. write <tt>${FOO}</tt> instead of <tt>$FOO</tt>.
</li>
</div><div class="substance">
<label class="ocn"><a name="652" href="#652" class="lnkocn">652</a></label>
<li class="bullet" id="o652">
Always protect variables with quotes to respect potential whitespaces: write <tt>"${FOO}"</tt> not <tt>${FOO}</tt>.
</li>
</div><div class="substance">
<label class="ocn"><a name="653" href="#653" class="lnkocn">653</a></label>
<li class="bullet" id="o653">
For consistency reasons, always use quotes when assigning values to variables:
</li>
</div><div class="substance">
<label class="ocn"><a name="654" href="#654" class="lnkocn">654</a></label>
<p class="i0" id="o654">
Bad:
</p>
</div><div class="substance">
<label class="ocn"><a name="655" href="#655" class="lnkocn">655</a></label>
<p class="code" id="o655">
FOO=bar<br /><br />
</p>
</div><div class="substance">
<label class="ocn"><a name="656" href="#656" class="lnkocn">656</a></label>
<p class="i0" id="o656">
Good:
</p>
</div><div class="substance">
<label class="ocn"><a name="657" href="#657" class="lnkocn">657</a></label>
<p class="code" id="o657">
FOO="bar"<br /><br />
</p>
</div><div class="substance">
<label class="ocn"><a name="658" href="#658" class="lnkocn">658</a></label>
<li class="bullet" id="o658">
If multiple variables are used, quote the full expression:
</li>
</div><div class="substance">
<label class="ocn"><a name="659" href="#659" class="lnkocn">659</a></label>
<p class="i0" id="o659">
Bad:
</p>
</div><div class="substance">
<label class="ocn"><a name="660" href="#660" class="lnkocn">660</a></label>
<p class="code" id="o660">
if [ -f "${FOO}"/foo/"${BAR}"/bar ]<br />
then<br />
foobar<br />
fi<br /><br />
</p>
</div><div class="substance">
<label class="ocn"><a name="661" href="#661" class="lnkocn">661</a></label>
<p class="i0" id="o661">
Good:
</p>
</div><div class="substance">
<label class="ocn"><a name="662" href="#662" class="lnkocn">662</a></label>
<p class="code" id="o662">
if [ -f "${FOO}/foo/${BAR}/bar" ]<br />
then<br />
foobar<br />
fi<br /><br />
</p>
</div><div class="substance">
<label class="ocn"><a name="663" href="#663" class="lnkocn">663</a></label>
<p class="bold" id="o663"><a name="663"></a> <a name="h14.5" id="h14.5"></a>
<a name="14.5" ></a><a name="h14.5" ></a>14.5 Miscellaneous
</p>
</div><div class="substance">
<label class="ocn"><a name="664" href="#664" class="lnkocn">664</a></label>
<li class="bullet" id="o664">
Use "<tt>|</tt>" (without the surround quotes) as a seperator in calls to sed, e.g. "<tt>sed -e 's|foo|bar|'</tt>" (without "").
</li>
</div><div class="substance">
<label class="ocn"><a name="665" href="#665" class="lnkocn">665</a></label>
<li class="bullet" id="o665">
Don't use the <tt>test</tt> command for comparisons or tests, use "<tt>[</tt>" "<tt>]</tt>" (without ""); e.g. "<tt>if [ -x /bin/foo ]; ...</tt>" and not "<tt>if test -x /bin/foo; ...</tt>".
</li>
</div><div class="substance">
<label class="ocn"><a name="666" href="#666" class="lnkocn">666</a></label>
<li class="bullet" id="o666">
Use <tt>case</tt> wherever possible over <tt>test</tt>, as it's easier to read and faster in execution.
</li>
</div></div><br /><div class="main_column">
<table summary="segment navigation band" bgcolor="#ffffff" width="100%"><tr>
<td width="70%" align="center">
<table summary="segment navigation available documents types: toc,doc,pdf,concordance" border="0" cellpadding="3" cellspacing="0">
<tr>
<td align="center" bgcolor="#ffffff">
<td align="center" bgcolor="#ffffff">
<a href="sisu_manifest.en.html" target="_top" >
<font face="verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman" size="2">
[ document manifest ]
</font>
</a>
</td>
</tr></table>
</td>
<td width="5%" align="right">
<table summary="segment navigation pre/next" border="0" cellpadding="3" cellspacing="0">
<tr>
<td align="center" bgcolor="#ffffff">
<a href="bugs.en.html" target="_top" >
<img border="0" width="22" height="22" src="../_sisu/image_sys/arrow_prev_red.png" alt="<< previous" />
</a>
</td>
<td align="center" bgcolor="#ffffff">
<a href="toc.en.html" target="_top" >
<img border="0" width="22" height="22" src="../_sisu/image_sys/arrow_up_red.png" alt="TOC" />
</a>
</td>
<td align="center" bgcolor="#ffffff">
<a href="procedures.en.html" target="_top" >
<img border="0" width="22" height="22" src="../_sisu/image_sys/arrow_next_red.png" alt="next >>" />
</a>
</td>
<td>
</td></tr>
</table>
</td></tr>
</table>
<table summary="segment hidden control pre and next" width="100%" border="0" cellpadding="0" bgcolor=#eeeeee align="center">
<tr><td align="left">
<a href="bugs.en.html" target="_top" >
<img border="0" width="100%" height="20" src="../_sisu/image_sys/dot_white.png" alt="<" />
</a>
</td>
<td align="center">
<a href="toc.en.html" target="_top" >
<img border="0" width="100%" height="20" src="../_sisu/image_sys/dot_white.png" alt="^" />
</a>
</td>
<td align="right">
<a href="procedures.en.html" target="_top" >
<img border="0" width="100%" height="20" src="../_sisu/image_sys/dot_white.png" alt=">" />
</a>
</td></tr>
</table>
</div><div class="main_column">
<a name="bottom" id="bottom"></a>
<a name="down" id="down"></a>
<a name="end" id="end"></a>
<a name="finish" id="finish"></a>
<a name="stop" id="stop"></a>
<a name="credits" id="credits"></a>
</div></div></body>
</html>
|