diff --git a/docs/coding-style.txt b/docs/coding-style.txt new file mode 100644 index 0000000..c7008c2 --- /dev/null +++ b/docs/coding-style.txt @@ -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 + +