1
0
Fork 0
mirror of synced 2024-11-25 00:35:34 -05:00

Use diff in Code Style Guide, as shown in https://calmcode.io/til/md-diffs.html

Eric Nielsen 2022-01-10 14:57:08 -05:00
parent 177f826f87
commit 1cc3006502

@ -22,19 +22,23 @@ Be reasonable. Keeping within 80 characters is recommended, 120 is the maximum.
Variables Variables
--------- ---------
Limit the scope of variables to `local` when within a function.
Wrap your variables in `${curly} ${braces}`. Wrap your variables in `${curly} ${braces}`.
Use `${snake_case}` for your variable names. Use `${snake_case}` for your variable names.
Use existing variables whenever possible: Use existing variables whenever possible:
* Good: `${PWD}` `${USER}` ```diff
* Bad: `$(pwd)` `$(whoami)` - 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: 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` ```diff
* Bad: `: ${VAR=1}` - : ${VAR=1}
+ if (( ! ${+VAR} )) typeset -g VAR=1
```
Flow logic Flow logic
---------- ----------