From 4123d337a7dce0a41eb309792d8f4551e3e97e3c Mon Sep 17 00:00:00 2001 From: lw-everestlinux Date: Fri, 18 Nov 2022 08:09:01 -0500 Subject: [PATCH] init --- docs/coding-style.txt | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docs/coding-style.txt 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 + +