From 5ee61cef2f4137cda1a3e8dbcd794894a54a2e63 Mon Sep 17 00:00:00 2001 From: csexton Date: Tue, 28 Jun 2011 08:57:20 -0700 Subject: [PATCH] First hack at a little structure. --- Coding-style-guide.md | 44 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/Coding-style-guide.md b/Coding-style-guide.md index be2b534..9559b01 100644 --- a/Coding-style-guide.md +++ b/Coding-style-guide.md @@ -1,5 +1,41 @@ -* lower_case with underscores -* no CamelCase -* GLOBAL_VARIABLES -* ... \ No newline at end of file +## Variables + +Meaningful self documenting names should be used, if the variable name does not make it reasonably obvious as to the meaning, appropriate comments should be added. + +Preferred naming convention is to use `snake_case` names, and not `CamelCase` or `somethingElse`. + +`ALL_CAPS` is reserved for globals, any local variables should be in `snake_case` + +Variables name should not clobber command names, such as `dir`, `pwd` + + +## Functions + +Braces should be on the same line as the function name: + + helpful() { + ... + } + +Private or utility functions should be prefixed with an underscore: + + _helper_util() { + ... + } + + +## General + +Indenting should be done with 2 spaces. + +When possible, use environment variables instead of forking a command. + + $(pwd) # don't use, forks a new process + $PWD # do use + +`if-then` statements should be on one line: + + if [[ -f $1 ]]; then + ... + fi