diff --git a/Code-Style-Guide.md b/Code-Style-Guide.md index ff6bc1c..a6811b9 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 ----------- @@ -9,6 +9,15 @@ Not hard tabs. Not four spaces. Not however many spaces you feel like. 2 spaces. +When using line continuations, indent with 2 extra spaces: + +``` +for x in a very very very very \ + very very very long line; do + print ${x} +done +``` + Line Length ----------- @@ -19,22 +28,23 @@ Variables Limit the scope of variables to `local` if within a function. -Wrap your variables in `${curly}` `${braces}`. +Wrap your variables in `${curly} ${braces}`. Use `${snake_case}` for your variables. **NOT** `${camelCase}` or `${FuCk_you_iDoWhat_i_want}`. -Use existing variables whenever possible. - -| Bad | Good | -| --- | ---- | -| `$(pwd)` | `${PWD}` | -| `$(whoami)` | `${USER}` | +Use existing variables whenever possible: +* Good: `${PWD}` `${USER}` +* Bad: `$(pwd)` `$(whoami)` Flow Logic ---------- -Place `; do` `; then` on the same line as `while`, `for`, and `if`. +For short single commands, prefer one-liners: +* `for` with the zsh syntax: `for x (foo bar) print ${x}` +* `&&` instead of if: `(( ! ${+FOO} )) && FOO='bar'` + +Otherwise just place `; do` `; then` on the same line as `while`, `for ... in`, and `if`. Functions ---------