init
This commit is contained in:
parent
18fbe3c236
commit
4123d337a7
45
docs/coding-style.txt
Normal file
45
docs/coding-style.txt
Normal file
@ -0,0 +1,45 @@
|
||||
Note: this document mainly focuses on shell scripts. For other languages, see the appropriate document.
|
||||
|
||||
Everest scripts should follow a relatively similar coding style.
|
||||
|
||||
1 - Shebangs
|
||||
|
||||
Every script MUST start with a shebang pointing to /bin/sh
|
||||
|
||||
#!/bin/sh
|
||||
|
||||
This ensures the script is shell-agnostic (unless you're weird and symlinked /bin/fish to /bin/sh)
|
||||
|
||||
2 - Functions
|
||||
|
||||
Most scripts must be written with functions in mind. This improves code readability and reproducibility.
|
||||
|
||||
myfunction() {
|
||||
printf "hello world\n"
|
||||
exit 0
|
||||
}
|
||||
|
||||
3 - Output
|
||||
|
||||
Scripts that output color MUST call the variable as follows:
|
||||
|
||||
${color}
|
||||
|
||||
This ensures there are no extra spaces.
|
||||
|
||||
All print statements MUST end with a newline ("\n") statement.
|
||||
|
||||
4 - Arguments
|
||||
|
||||
Arguments should be implemented in the following way:
|
||||
|
||||
case $1 in
|
||||
arg1)
|
||||
somefunction "$@"
|
||||
;;
|
||||
arg2)
|
||||
somefunction "$@"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user