From 671bb82a46a982ee580c3445339b09c742c6f686 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 9 Apr 2019 22:44:40 +0200 Subject: [PATCH] Fix shellcheck issues --- Makefile | 5 ++++- cdist/conf/type/__ssh_authorized_keys/manifest | 1 + scripts/debug-dump.sh | 16 ++++++++-------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index e140d383..4ed97c7b 100644 --- a/Makefile +++ b/Makefile @@ -274,11 +274,14 @@ shellcheck-local-gencodes: shellcheck-remote-gencodes: @find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 +shellcheck-scripts: + @$(SHELLCHECKCMD) scripts/debug-dump.sh || exit 0 + shellcheck-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes shellcheck-types: shellcheck-type-explorers shellcheck-manifests shellcheck-gencodes -shellcheck: shellcheck-global-explorers shellcheck-types +shellcheck: shellcheck-global-explorers shellcheck-types shellcheck-scripts shellcheck-type-files: @find cdist/conf/type -type f -path "*/files/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index 8d702875..a8ded2f6 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -69,6 +69,7 @@ while read -r key; do set -- "$@" --key "$key" set -- "$@" --state "$state" if [ -f "$__object/parameter/option" ]; then + # shellcheck disable=SC2046 set -- "$@" $(printf -- '--option %s ' $(cat "$__object/parameter/option")) fi if [ -f "$__object/parameter/comment" ]; then diff --git a/scripts/debug-dump.sh b/scripts/debug-dump.sh index d52273a6..ac1190b7 100755 --- a/scripts/debug-dump.sh +++ b/scripts/debug-dump.sh @@ -204,7 +204,7 @@ or= print_verbose() { - if [ ${verbose} -ge $1 ] + if [ "${verbose}" -ge "$1" ] then printf "%s\n" "$2" fi @@ -214,7 +214,7 @@ hor_line() { if [ $# -gt 0 ] then - c=$1 + c="$1" else c='=' fi @@ -289,7 +289,7 @@ set -- '.' "$@" -exec awk -v prefix="${filename_prefix}" "{print prefix ${ln} \$ print_verbose 2 "Using cache dir: ${cache_dir}" OLD_PWD=$(pwd) -cd "${cache_dir}" +cd "${cache_dir}" || exit # If no host is specified then search all. [ -z "${hosts}" ] && hosts="-" @@ -310,16 +310,16 @@ do do dir=$(dirname "${d}") - print_verbose 0 "target host: $(cat ${dir}/target_host), host directory: ${dir}" - hor_line + print_verbose 0 "target host: $(cat "${dir}/target_host"), host directory: ${dir}" + hor_line '=' PREV_PWD=$(pwd) - cd "${dir}" + cd "${dir}" || exit # set -x find "$@" # set +x - cd "${PREV_PWD}" + cd "${PREV_PWD}" || exit done IFS="${OLD_IFS}" done -cd "${OLD_PWD}" +cd "${OLD_PWD}" || exit