1
0
Fork 0
mirror of synced 2024-12-28 08:53:21 -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
---------
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
----------