Commit 1a3c8638 authored by Dylan Araps's avatar Dylan Araps

docs: update

parent ffd711a4
......@@ -41,6 +41,8 @@ request on the repo and our Travis.ci hook will run ShellCheck for you.
## No no's
- Don’t use `echo`.
- Use `printf "%s\n"`
- Don’t use `bc`.
- Don’t use `sed`.
- Use `bash`'s built-in [parameter expansion](http://wiki.bash-hackers.org/syntax/pe).
......@@ -52,21 +54,21 @@ request on the repo and our Travis.ci hook will run ShellCheck for you.
## If Statements
If the test only has one command inside of it; use the compact `if`
If the test only has one command inside of it; use the compact test
syntax. Otherwise the normal `if`/`fi` is just fine.
```sh
# Bad
if [[ "$var" ]]; then
echo "$var"
printf "%s\n" "$var"
fi
# Good
[[ "$var" ]] && echo "$var"
[[ "$var" ]] && printf "%s\n" "$var"
# Also good (Use this for longer lines).
[[ "$var" ]] && \
echo "$var"
printf "%s\n" "$var"
```
......@@ -77,16 +79,16 @@ Case statements need to be formatted in a specific way.
```sh
# Good example (Notice the indentation).
case "$var" in
1) echo 1 ;;
1) printf "%s\n" 1 ;;
2)
echo 1
echo 2
printf "%s\n" "1"
printf "%s\n" "2"
;;
*)
echo 1
echo 2
echo 3
printf "%s\n" "1"
printf "%s\n" "2"
printf "%s\n" "3"
;;
esac
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment