From 353b8a846f5755050928c03f4dc5a28b5959a770 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 2 Apr 2015 14:58:35 +0000 Subject: [PATCH] Introduce CODING_STYLE Signed-off-by: Stefano Stabellini --- CODING_STYLE | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 CODING_STYLE diff --git a/CODING_STYLE b/CODING_STYLE new file mode 100644 index 0000000..a18b75d --- /dev/null +++ b/CODING_STYLE @@ -0,0 +1,78 @@ +RAISIN CODING STYLE +=================== + + +Shell version compliance +------------------------ + +Although we are requiring bash to run at the moment, please don't make +assumption on the bash version available. Use modern features only when +no older constructs do what you need. + + +Indentation +----------- + +Use four spaces to indent. + + +Line width +---------- + +Lines are limited to 80 characters. + + +Functions +--------- + +Use the function keyword and () to define a function. Place the opening +brace on the same line and the closing brace on a line by itself. +Example: + +function do_something () { + echo something +} + + +Tests +----- + +Use "test" to make a test. Do not use [. Do not use [[ unless you have a +good reason. + + +Subshell +-------- + +Use `` to execute a command in a subshell. + + +Numeric tests +------------- + +Use expr for calculations. + + +Awk +--- + +Use cut, tr, bash 4+ and sed instead of awk when possible, in this order. + + +Block structure +--------------- + +for loops, place do on a new line: + +for i in $LIST +do + echo do something +done + + +if statements, place then on a new line: + +if test -z "$VAR" +then + echo do something +fi -- 2.39.5