You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: code-standards/style-guide.md
+27-28Lines changed: 27 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
# Style Guide
2
2
3
-
In order to make LinuxGSM as coherent as possible, we adopted some code conventions to follow.
3
+
In order to make LinuxGSM as coherent as possible, we adopted some code conventions to follow.\
4
4
Here are some of them.
5
5
6
6
## Variables
7
7
8
8
#### Naming variables
9
9
10
-
Variables should be made of lowercase letters only and should be descriptive enough to understand its purpose \(even if the variable is longer that preferred\).
10
+
Variables should be made of lowercase letters only and should be descriptive enough to understand its purpose (even if the variable is longer that preferred).
11
11
12
12
### Defining variables
13
13
@@ -42,15 +42,15 @@ find "${executabledir}/bin"
42
42
43
43
If statements should look like the following
44
44
45
-
```text
45
+
```
46
46
if [ "${shortname}" == "csgo" ];then
47
47
# content
48
48
fi
49
49
```
50
50
51
51
if statements with multiple options like so
52
52
53
-
```text
53
+
```
54
54
if [ "${shortname}" == "csgo" ]||[ "${shortname}" == "css" ]; then
55
55
# content
56
56
fi
@@ -74,26 +74,26 @@ fi
74
74
75
75
### Expression Standards
76
76
77
-
Common if expressions LinuxGSM uses. More expressions [here](http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html).
77
+
Common if expressions LinuxGSM uses. More expressions [here](http://tldp.org/LDP/Bash-Beginners-Guide/html/sect\_07\_01.html).
-n is used to check is a variable is set and not if it exists
96
-
-v is used to check if a variable exists and not it is set
95
+
\-n is used to check is a variable is set and not if it exists\
96
+
\-v is used to check if a variable exists and not it is set
97
97
98
98
```bash
99
99
var="set"
@@ -109,7 +109,7 @@ if [ -z "${var}" ]; then
109
109
fi
110
110
```
111
111
112
-
```text
112
+
```
113
113
var=""
114
114
# OR
115
115
var="set"
@@ -118,7 +118,7 @@ if [ -v var ]; then
118
118
fi
119
119
```
120
120
121
-
```text
121
+
```
122
122
# var is missing
123
123
if [ ! -v var ]; then
124
124
# Variable does not exist
@@ -139,7 +139,7 @@ done
139
139
140
140
## Comments
141
141
142
-
As English is not always the native language of a developer, comments should use a formal writing style and be straight to the point. If unsure this short formal writing [guide](http://www2.ivcc.edu/rambo/tip_formal_writing_voice.htm) will help.
142
+
As English is not always the native language of a developer, comments should use a formal writing style and be straight to the point. If unsure this short formal writing [guide](http://www2.ivcc.edu/rambo/tip\_formal\_writing\_voice.htm) will help.
143
143
144
144
```bash
145
145
# Using comments help developers understand complex code, but should be used sparingly.
@@ -166,27 +166,27 @@ fn_myfunction(){
166
166
167
167
## Automated Messages
168
168
169
-
Automated messages are used with any commands that are non-interactive. Examples of this include Start, Stop and Monitor. There are various different alert messages available see [Exit-Codes](exit-codes.md) for details.
169
+
Automated messages are used with any commands that are non-interactive. Examples of this include Start, Stop and Monitor. There are various different alert messages available see [Exit-Codes](broken-reference) for details.
170
170
171
171
Each automated message starts with `fn_print_dots` to show a process is happening but with no known outcome.
172
172
173
173
`fn_print_dots`
174
174
175
-
```text
175
+
```
176
176
[ .... ] Starting fctrserver:
177
177
```
178
178
179
179
Once an outcome of a process is known the message uses an outcome message like `fn_print_ok` or `fn_print_fail`
180
180
181
181
fn\_print\_ok
182
182
183
-
```text
183
+
```
184
184
[ OK ] Starting fctrserver: Factorio Server
185
185
```
186
186
187
187
The option of a newline is also available by appending `_nl` for example `fn_print_ok_nl`. This will add a carriage return to the message preventing it being overwritten by the next message.
188
188
189
-
```text
189
+
```
190
190
[ OK ] Stopping fctrserver: Graceful: CTRL+c: 2: OK
191
191
[ .... ] Starting fctrserver: Factorio Server
192
192
```
@@ -197,15 +197,15 @@ Interactive messages contain extra detail at the begining of the message that is
197
197
198
198
### Interactive Messages
199
199
200
-
Interactive messages are used with any commands that have interactive elements. Examples of this include Install, console and debug. There are various different alert messages available see \[\[Exit-Codes\]\] for details.
200
+
Interactive messages are used with any commands that have interactive elements. Examples of this include Install, console and debug. There are various different alert messages available see \[\[Exit-Codes]] for details.
201
201
202
-
```text
202
+
```
203
203
Warning! If fctrserver is already running it will be stopped.
204
204
```
205
205
206
206
standard echo commands are normally used to supplement an alert or if an alert is not required. Bullet points can also be used
207
207
208
-
```text
208
+
```
209
209
Information! Press "CTRL+b" then "d" to exit console.
210
210
Warning! Do NOT press CTRL+c to exit.
211
211
* https://docs.linuxgsm.com/commands/console
@@ -214,4 +214,3 @@ Warning! Do NOT press CTRL+c to exit.
214
214
#### Characteristics
215
215
216
216
Treat interactive messages as a standard sentence. All messages must begin with a capital and end with a full stop
Copy file name to clipboardExpand all lines: getting-started/developing-linuxgsm.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,11 +20,11 @@ A user can also run the install again if they want multiple instances of the sam
20
20
21
21
## Modules
22
22
23
-
Modules are individual bash scripts containing code and functions that complete specific tasks. See the [modules](../code-standards/modules.md) page for more info.
23
+
Modules are individual bash scripts containing code and functions that complete specific tasks. See the [modules](broken-reference) page for more info.
24
24
25
25
## Commands
26
26
27
-
Within LInuxGSM there are many commands that a user will run to complete tasks such as start, stop, monitor, and details. Command scripts are stored will all other modules and are always named something like `command_install.sh`. See the [commands](../code-standards/commands.md) page for more info.
27
+
Within LInuxGSM there are many commands that a user will run to complete tasks such as start, stop, monitor, and details. Command scripts are stored will all other modules and are always named something like `command_install.sh`. See the [commands](broken-reference) page for more info.
0 commit comments