From 46d100234e0ad81f7e63f854021a95c6d2616eac Mon Sep 17 00:00:00 2001 From: Dirk Wetter Date: Mon, 21 Dec 2015 17:42:37 +0100 Subject: [PATCH] Updated Coding Style (markdown) --- Coding-Style.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Coding-Style.md b/Coding-Style.md index 501e358..83aab16 100644 --- a/Coding-Style.md +++ b/Coding-Style.md @@ -2,11 +2,14 @@ ### This is a short brain dump which is far from being complete +* PR * + * you make the life of the maintainer easier if it's only **one** patch w/ **one** functional change per PR + * Global variables - * in CAPS * use them only when necessary + * in CAPS * initialize them - * use readonly and variable types + * 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) @@ -18,23 +21,18 @@ * 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.). - -* be careful with very advanced bash features. Mac OS X is still somewhat behind with bash -- it uses bash version 3 - ([http://tldp.org/LDP/abs/html/bashver4.html](differences)) - * 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 * don't use highly system depended binaries (rpm, ipconfig, ..) as it is not portable or requires lot's of efforts and ugly code to be portable. -* every operation (string, etc.) which works with bash internall functions: use them whenever possible (replacing tr/sed/awk) - +* every operation (string, etc.) which works with bash internal functions: use them whenever possible (replacing tr/sed/awk), see e.g. http://www.cyberciti.biz/tips/bash-shell-parameter-substitution-2.html * avoid a mix of e.g. (sed and awk) or (cut and sed) or (sed, tr and \). +* be careful with very advanced bash features. Mac OS X is still using bash version 3 ([http://tldp.org/LDP/abs/html/bashver4.html](differences)) +* especially with ``sed`` you need to be careful as GNU sed is only 80% compatible with BSD sed (`sed -i`,` \n`, `\t`, etc.). * always use a return value for a function/method