-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from andresgongora/develop
Update master to v1.2
- Loading branch information
Showing
15 changed files
with
778 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Ignore developer's `test` and `config` files | ||
*.config | ||
*.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ The following list is roughly sorted in reverse cronological order. | |
|
||
|
||
* olmari <[email protected]> | ||
Variable padding for _status.sh_ | ||
Major improvements to `status.sh` | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<!--------------------------------------+--------------------------------------> | ||
# Bash coding style | ||
<!--------------------------------------+--------------------------------------> | ||
|
||
This document is intended as a primer and reference to ensure a consistent style | ||
between all scripts and auxiliary files (e.g. config files). This file will | ||
slowly grow as needed. | ||
|
||
|
||
|
||
|
||
|
||
<!--------------------------------------+--------------------------------------> | ||
# Variables | ||
<!--------------------------------------+--------------------------------------> | ||
|
||
### Global variables | ||
|
||
Avoid global variables unless strictly needed. Even if they are meant to be | ||
unset at the end of the script, it is always possible that the script stops | ||
prematurely or that the developer forgets about it. Global variables can | ||
_contamiante_ the user's run space and lead to unexpected behaviour. | ||
|
||
Global variables are named in uppercase and using underscores. | ||
|
||
``` | ||
MY_VAR=2 | ||
MY_SUPER_STRING="Hello world!" | ||
``` | ||
|
||
|
||
|
||
## Local variables | ||
|
||
Declare _local_ variables using `local` rather than `declare` or other options. | ||
Because local variables can not be declared in the main body of the script, | ||
this will enforce wrapping everithing into functions, which is not a bad thing. | ||
|
||
Local variables are named all in lower case and using underscores. | ||
|
||
``` | ||
local my_var=2 | ||
local my_super_string="Hello world!" | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
<!--------------------------------------+--------------------------------------> | ||
# Functions | ||
<!--------------------------------------+--------------------------------------> | ||
|
||
Each function shall do only one thing, otherwise, the function shall be | ||
divided into two separate functions. Following this rule is not always easy, | ||
but it ensures that the code is easy to read, modular and reusable. | ||
|
||
Functions are named using camel case, with the first letter in lower case. Also, | ||
all names must be or contain a verb that describes the action that will | ||
performed by the function. An exception to this rule is when the function | ||
returns (prints) a boolean. In this case, the function starts with `is` or | ||
`has` to make it easier to read. | ||
|
||
``` | ||
getNewValue() | ||
printTemperature() | ||
lockSystem() | ||
getGPSCoordinates() | ||
reload() | ||
isSystemOverloaded() | ||
hasEnoughMemory() | ||
``` | ||
|
||
|
||
|
||
|
||
<!--------------------------------------+--------------------------------------> | ||
# Tabs vs spaces | ||
<!--------------------------------------+--------------------------------------> | ||
|
||
* **Tabs** for indenting | ||
* **Spaces** for alignment (its rarely needed) | ||
|
||
``` | ||
getData() | ||
{ | ||
<tab> if [ $VAR -gt 2 ]; then | ||
<tab> <tab> aux_var=$(pollSystem "/home/user/made/up/path" |\ | ||
<tab> <tab> <spaces............> head -n 1" |\ | ||
<tab> <tab> <spaces............> sed '/somereggexblackmagic' | | ||
<tab> <tab> <spaces............> tr -d " ") | ||
<tab> <tab> echo "$aux_var" | ||
<tab> fi | ||
} | ||
``` | ||
|
||
**Why??** - Because some of us just want to see the world burn | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,7 +234,7 @@ getEffectCode() | |
none) | ||
echo $NONE | ||
;; | ||
defualt) | ||
default) | ||
echo $NONE | ||
;; | ||
bold) | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.