diff --git a/Code-Style-Guide.md b/Code-Style-Guide.md index 8564d70..8e2e500 100644 --- a/Code-Style-Guide.md +++ b/Code-Style-Guide.md @@ -28,16 +28,16 @@ Use `${snake_case}` for your variable names. Use existing variables whenever possible: ```diff -- print "$(whoami) in $(pwd)" -+ print "${USER} in ${PWD}" +-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: ```diff -- : ${VAR=1} -+ if (( ! ${+VAR} )) typeset -g VAR=1 +-: ${VAR=1} ++if (( ! ${+VAR} )) typeset -g VAR=1 ``` Flow logic @@ -59,10 +59,11 @@ Functions --------- Use POSIX syntax: -``` -foo() { - print 'bar' -} +```diff +-function foo { ++foo() { + print bar + } ``` NOTE: There *is* a difference between this and ksh style, but unless you know what it is and you're **sure** you need it, use POSIX.