From ed7d5623ad8a8478dceda955f50f3b6dcdf2913f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 26 Mar 2017 04:38:35 -0600 Subject: [PATCH] fix: attempt to pass shellcheck on os x --- contrib/dokku_client.sh | 2 +- plugins/20_events/install | 1 + plugins/checks/check-deploy | 6 +++--- plugins/common/functions | 2 +- plugins/git/functions | 2 +- plugins/logs/subcommands/default | 3 ++- plugins/ps/functions | 4 ++-- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/contrib/dokku_client.sh b/contrib/dokku_client.sh index 2e2f6ae78..85c1c1480 100755 --- a/contrib/dokku_client.sh +++ b/contrib/dokku_client.sh @@ -125,7 +125,7 @@ main() { else APP="$APP_ARG" fi - if git remote add $DOKKU_GIT_REMOTE "dokku@$DOKKU_REMOTE_HOST:$APP"; then + if git remote add "$DOKKU_GIT_REMOTE" "dokku@$DOKKU_REMOTE_HOST:$APP"; then echo "-----> Dokku remote added at ${DOKKU_REMOTE_HOST} called ${DOKKU_GIT_REMOTE}" echo "-----> Application name is ${APP}" else diff --git a/plugins/20_events/install b/plugins/20_events/install index e6991005f..cdc5cb497 100755 --- a/plugins/20_events/install +++ b/plugins/20_events/install @@ -10,6 +10,7 @@ flag_rsyslog_needs_restart=n # This can be done unconditionally as mkdir -p # exits gracefully if the path already exists +# shellcheck disable=SC2174 mkdir -m 775 -p "$DOKKU_LOGS_DIR" case "$DOKKU_DISTRO" in arch|debian|centos) diff --git a/plugins/checks/check-deploy b/plugins/checks/check-deploy index 7652331e4..7afe7a56b 100755 --- a/plugins/checks/check-deploy +++ b/plugins/checks/check-deploy @@ -74,7 +74,7 @@ checks_check_deploy() { # after successfully copying the file. Thus, we suppress stderr. # ref: https://github.com/dotcloud/docker/issues/3986 local CHECK_DEPLOY_TMP_WORK_DIR=$(mktemp -d /tmp/dokku_CHECKS.XXXXX) - docker cp $DOKKU_APP_CONTAINER_ID:/app/CHECKS "$CHECK_DEPLOY_TMP_WORK_DIR" 2> /dev/null || true + docker cp "$DOKKU_APP_CONTAINER_ID:/app/CHECKS" "$CHECK_DEPLOY_TMP_WORK_DIR" 2> /dev/null || true local FILENAME=${CHECK_DEPLOY_TMP_WORK_DIR}/CHECKS @@ -107,8 +107,8 @@ checks_check_deploy() { dokku_log_info1 "Waiting for $DOKKU_DEFAULT_CHECKS_WAIT seconds ..." sleep "$DOKKU_DEFAULT_CHECKS_WAIT" - ! (is_container_running $DOKKU_APP_CONTAINER_ID) && dokku_log_fail "App container failed to start!!" - local container_restarts=$(docker inspect -f "{{ .RestartCount }}" $DOKKU_APP_CONTAINER_ID) + ! (is_container_running "$DOKKU_APP_CONTAINER_ID") && dokku_log_fail "App container failed to start!!" + local container_restarts="$(docker inspect -f "{{ .RestartCount }}" "$DOKKU_APP_CONTAINER_ID")" if [[ $container_restarts -ne 0 ]]; then docker stop "$DOKKU_APP_CONTAINER_ID" || true dokku_log_fail "App container failed to start!!" diff --git a/plugins/common/functions b/plugins/common/functions index e2843bf69..b14820b7b 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -142,7 +142,7 @@ verify_app_name() { local APP="$1" [[ ! -n "$APP" ]] && dokku_log_fail "(verify_app_name) APP must not be null" if [[ ! "$APP" =~ ^[a-z].* && ! "$APP" =~ ^[0-9].* ]]; then - [[ -d "$DOKKU_ROOT/$APP" ]] && rm -rf "$DOKKU_ROOT/$APP" + [[ -d "$DOKKU_ROOT/$APP" ]] && rm -rf "${DOKKU_ROOT:?}/$APP" dokku_log_fail "App name must begin with lowercase alphanumeric character" fi [[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist" diff --git a/plugins/git/functions b/plugins/git/functions index 4c6a4a62c..ceebfb5b1 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -30,7 +30,7 @@ git_build_app_repo() { git reset --hard FETCH_HEAD &> /dev/null suppress_output git submodule update --init --recursive GIT_DIR="$DOKKU_ROOT/$APP" git tag -d "$TMP_TAG" &> /dev/null || true - find -name .git -prune -exec rm -rf {} \; > /dev/null + find . -name .git -prune -exec rm -rf {} \; > /dev/null plugn trigger post-extract "$APP" "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" "$REV" diff --git a/plugins/logs/subcommands/default b/plugins/logs/subcommands/default index e97480c6a..14532f31d 100755 --- a/plugins/logs/subcommands/default +++ b/plugins/logs/subcommands/default @@ -17,7 +17,8 @@ logs_default_cmd() { shift 2; local TEMP=$(getopt -o htqn:p: --long help,tail,quiet,num:,ps: -n 'dokku logs' -- "$@") - if [[ $? != 0 ]]; then usage >&2 ; exit 1 ; fi + local EXIT_CODE="$?" + if [[ "$EXIT_CODE" != 0 ]]; then usage >&2 ; exit 1 ; fi eval set -- "$TEMP" local DOKKU_LOGS_LINE_NUMBERS="100" diff --git a/plugins/ps/functions b/plugins/ps/functions index 3191f88ef..f9f094df8 100755 --- a/plugins/ps/functions +++ b/plugins/ps/functions @@ -77,9 +77,9 @@ set_scale() { for procscale in "${SCALE_SETTINGS[@]}"; do local PROC_NAME=${procscale%%=*} local PROC_COUNT=${procscale#*=} - is_number $PROC_COUNT || dokku_log_fail "ps:scale $PROC_COUNT is not a number" + is_number "$PROC_COUNT" || dokku_log_fail "ps:scale $PROC_COUNT is not a number" dokku_log_info1_quiet "Scaling $APP:$PROC_NAME to $PROC_COUNT" - if (egrep -q ^${PROC_NAME}= "$DOKKU_SCALE_FILE" > /dev/null 2>&1); then + if (egrep -q "^${PROC_NAME}=" "$DOKKU_SCALE_FILE" > /dev/null 2>&1); then sed --in-place "s:^${PROC_NAME}=.*:$PROC_NAME=$PROC_COUNT:g" "$DOKKU_SCALE_FILE" else echo "$PROC_NAME=$PROC_COUNT" >> "$DOKKU_SCALE_FILE"