diff --git a/Code-Style-Guide.md b/Code-Style-Guide.md index a6811b9..4f96dd2 100644 --- a/Code-Style-Guide.md +++ b/Code-Style-Guide.md @@ -1,4 +1,4 @@ -These are the code style guidelines that should be followed when contributing to zim. +These are the code style guidelines that should be followed when contributing to Zim. Indentation ----------- @@ -18,7 +18,7 @@ for x in a very very very very \ done ``` -Line Length +Line length ----------- Be reasonable. Keeping within 80 characters is recommended, 120 is the maximum. @@ -37,15 +37,21 @@ Use existing variables whenever possible: * Good: `${PWD}` `${USER}` * Bad: `$(pwd)` `$(whoami)` -Flow Logic +Flow logic ---------- For short single commands, prefer one-liners: -* `for` with the zsh syntax: `for x (foo bar) print ${x}` -* `&&` instead of if: `(( ! ${+FOO} )) && FOO='bar'` +* `for` with the Zsh syntax: `for x (foo bar) print ${x}` +* `&&` instead of if: `[[ -d ${dir} ]] && cd ${dir}` Otherwise just place `; do` `; then` on the same line as `while`, `for ... in`, and `if`. +Use `(( ))` for arithmetic conditions, and `[[ ]]` for other condition evaluations. Don't use `[ ]`. + +With arithmetic conditions: +* Don't use `$` in front of variables: `(( var > 1 ))` +* Unless some substitution is needed: `(( ${#var} > 1 ))` + Functions --------- @@ -63,4 +69,3 @@ Misc Do **NOT** use backticks ``` ` ``` to execute something in a subshell. This GRINDS MY GEARS. `$(print "use parentheses")` -