diff --git a/Code-Style-Guide.md b/Code-Style-Guide.md index 1dbbd5b..8564d70 100644 --- a/Code-Style-Guide.md +++ b/Code-Style-Guide.md @@ -22,19 +22,23 @@ Be reasonable. Keeping within 80 characters is recommended, 120 is the maximum. Variables --------- -Limit the scope of variables to `local` when within a function. - Wrap your variables in `${curly} ${braces}`. Use `${snake_case}` for your variable names. Use existing variables whenever possible: -* Good: `${PWD}` `${USER}` -* Bad: `$(pwd)` `$(whoami)` +```diff +- print "$(whoami) in $(pwd)" ++ print "${USER} in ${PWD}" +``` + +Limit the scope of variables to `local` when within a function. When declaring a global variable, be explicit and do it using `typeset -g`. This avoids warnings when `WARN_CREATE_GLOBAL` is set: -* Good: `if (( ! ${+VAR} )) typeset -g VAR=1` -* Bad: `: ${VAR=1}` +```diff +- : ${VAR=1} ++ if (( ! ${+VAR} )) typeset -g VAR=1 +``` Flow logic ----------