This commit is contained in:
lw-everestlinux 2022-11-18 08:09:01 -05:00
parent 18fbe3c236
commit 4123d337a7

45
docs/coding-style.txt Normal file
View 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