first draft

Dirk Wetter 2015-12-07 17:37:22 +01:00
parent b96f70ab6e
commit bb6b80456e

@ -1 +1,43 @@
## Coding Style
## Coding Style
### This is a short brain dump which is far from being complete
* Global variables
* in CAPS
* use them only when necessary
* initialize them
* use readonly and variable types
* if it's going to be a cmd line switch, there has to be also a global ENV variable which can be used without the switch (see e.g. SNEAKY or SSL_NATIVE)
* local variables (all_lower_case)
* declare them before usage
* if unclear initialize them
* use "speaking variables" but don't overdo it with the length
* test before PR! If it's a check you need two bad and two good examples which should work as expected (compare results e.g. with SSLlabs)
* don't use backticks anymore
* use double square instead of single square brackets
* use [shellcheck](https://github.com/koalaman/shellcheck) if possible
* especially with sed you need to be careful as GNU sed is only 80% compatible with BSD sed (`sed -i`,` \n`, `\t`, etc.).
* don't use additional binaries
* if you really, really need to use an additional one make sure it's available on the system before calling it
* every operation (string, etc.) which works with bash internall functions: use them whenever possible (replacing tr/sed/awk)
* avoid a mix of e.g. (sed and awk) or (cut and sed) or (sed, tr and \<whatsoever\>).
* always use a return value for a function/method
* use the short functions / methods
* count_words() / count_lines() / count_ciphers()
* strip_lf() / strip_spaces()
* toupper()
* newline_to_spaces()
* is_number() / is_ipv4addr() / is_ipv6addr()