From 1a3c8638e1b09a691cf92279e08a69e63b1d6d90 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 4 May 2018 17:05:13 +1000 Subject: [PATCH] docs: update --- CONTRIBUTING.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 08e5a934..5858df73 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 ```