From aa9d8fdc9d939b67394b2bff138afea1afa4369d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Remseth?= Date: Fri, 24 Aug 2018 08:57:35 +0200 Subject: [PATCH] Add a bit of coding standard for how to avoid the issue we saw in the init shellscript for starting prime yesterday. (#226) --- CONTRIBUTING.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 18371448a..e4563d25b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -114,6 +114,20 @@ by the github repository. It should all be open. * [Greg's wiki about shell scripting is a very good resource](http://mywiki.wooledge.org/) * For complex output (multiple lines etc.), consider using "printf" instead of the simple "echo". +* Scripts, in particular scripts that are run during startup of containers + either for production or testing, should die cleanly and visibly as soon as + possible if they have to. For instance, if the script depends on + an executable that may be missing, the script should test for the + existance of the executable before any of the script's "payload" is + executed. Example: + + DEPENDENCIES="foo bar baz gazonk" + for dep in $DEPENDENCIES; do + if [[ -z "$(type $dep)" ]] ; then + echo "Cannot locate executable '${dep}', bailing out" + exit 1 + fi + done ## Kotlin