blob: 82c72f0843097b3052448490cbdab2e436fc1542 (
plain)
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
|
@macro contid{id}
@strong{[@anchor{\id\}\id\]}
@end macro
@node Contribution Guidelines
@chapter Contribution Guidelines
Thanks for taking your time to contribute! To maintain stylistic behaviour
throughout the repositories, one must adhere to these guidelines. Exceptions and
changes may occur with good reasoning.
@node Conventions
@section Conventions
@subsection General Conventions -- 00
These apply to each and every file on the repositories.
@itemize
@item
Try to keep the file readable. @contid{0010}
@itemize
@item
Characters on a line shouldn't exceed 100 characters excluding indentation. @contid{0011}
@item
Make sure you don't have code commented out during commit. Uncomment them
or remove them completely. @contid{0012}
@item
Do not add comments following the code, add them to the top of the code. It
makes it harder to read, and lines longer. @contid{0013}
Here is an example:
@example
# Good way of commenting.
your code goes here
your code goes here # Avoid this way of commenting.
@end example
@end itemize
@end itemize
@subsection Shell Conventions -- 10
Shell is central to Carbs Linux projects. Most of the tools and packages are
written in POSIX sh.
@itemize
@item
Use 4 spaces for indentation, instead of tabs. @contid{1010}
@item
Make sure you don't use bash-specific code. @contid{1020}
@item
Make sure you lint your code with @command{shellcheck} and if you are new to
POSIX sh, use @command{checkbashisms}. @contid{1030}
@item
Don't spawn new processes if you don't absolutely need to, especially during
string manipulation. @contid{1040}
@itemize
@item
Never use a program for text manupilation that isn't defined in the POSIX
standard. This includes @command{gawk} and @command{perl}. @contid{1041}
@item
Instead of @code{$(basename $file)}, use @code{$@{file##*@}}. @contid{1042}
@item
Instead of @code{$(dirname $file)}, use @code{$@{file%/*@}}. @contid{1043}
@end itemize
@example
# This is the same thing as @code{basename /path/to/test.asc .asc}
$ file=/path/to/test.asc file=$@{file##*/@} file=$@{file%.asc@}
$ echo $file
test
@end example
@item
Instead of backticks, use @verb{|$(..)|}. @contid{1050}
@end itemize
|