Suppress `which`'s output from format-checker.sh (#3232)
author이상규/동작제어Lab(SR)/Principal Engineer/삼성전자 <sg5.lee@samsung.com>
Thu, 18 Oct 2018 06:33:59 +0000 (15:33 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 18 Oct 2018 06:33:59 +0000 (15:33 +0900)
- Suppress output from `which` command
- Replace `which` to `command -v` for support builtin command also
- Remove function keywords for better portability

Signed-off-by: Sanggyu Lee <sg5.lee@samsung.com>
scripts/command/format-checker.sh

index 7c2b477..002dab3 100755 (executable)
@@ -1,25 +1,27 @@
 #!/bin/bash
 
-function pushd () {
+pushd () {
     command pushd "$@" > /dev/null
 }
 
-function popd () {
+popd () {
     command popd "$@" > /dev/null
 }
 
-function check_cpp_tool() {
-    which clang-format-3.9
-    if [[ $? -ne 0 ]]; then
+command_exists() {
+  command -v $1 > /dev/null 2>&1
+}
+
+check_cpp_tool() {
+    if ! command_exists clang-format-3.9; then
         echo "Error: clang-format-3.9 is not available."
         echo "       Please install clang-format-3.9."
         exit 1
     fi
 }
 
-function check_python_tool() {
-    which yapf
-    if [[ $? -ne 0 ]]; then
+check_python_tool() {
+    if ! command_exists yapf; then
         echo "Error: yapf is not available."
         echo "       Please install yapf."
         exit 1
@@ -35,7 +37,7 @@ function check_newline_cr() {
     fi
 }
 
-function check_cpp_files() {
+check_cpp_files() {
     DIRECTORIES_TO_BE_TESTED=$1
     DIRECTORIES_NOT_TO_BE_TESTED=$2
 
@@ -58,7 +60,7 @@ function check_cpp_files() {
     done
 }
 
-function check_python_files() {
+check_python_files() {
     DIRECTORIES_TO_BE_TESTED=$1
     DIRECTORIES_NOT_TO_BE_TESTED=$2