Fix shellcheck issues

This commit is contained in:
Darko Poljak 2019-04-09 22:44:40 +02:00
parent f6b318bb00
commit 671bb82a46
3 changed files with 13 additions and 9 deletions

View file

@ -274,11 +274,14 @@ shellcheck-local-gencodes:
shellcheck-remote-gencodes: shellcheck-remote-gencodes:
@find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 @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-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes
shellcheck-types: shellcheck-type-explorers shellcheck-manifests shellcheck-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: shellcheck-type-files:
@find cdist/conf/type -type f -path "*/files/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 @find cdist/conf/type -type f -path "*/files/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0

View file

@ -69,6 +69,7 @@ while read -r key; do
set -- "$@" --key "$key" set -- "$@" --key "$key"
set -- "$@" --state "$state" set -- "$@" --state "$state"
if [ -f "$__object/parameter/option" ]; then if [ -f "$__object/parameter/option" ]; then
# shellcheck disable=SC2046
set -- "$@" $(printf -- '--option %s ' $(cat "$__object/parameter/option")) set -- "$@" $(printf -- '--option %s ' $(cat "$__object/parameter/option"))
fi fi
if [ -f "$__object/parameter/comment" ]; then if [ -f "$__object/parameter/comment" ]; then

View file

@ -204,7 +204,7 @@ or=
print_verbose() print_verbose()
{ {
if [ ${verbose} -ge $1 ] if [ "${verbose}" -ge "$1" ]
then then
printf "%s\n" "$2" printf "%s\n" "$2"
fi fi
@ -214,7 +214,7 @@ hor_line()
{ {
if [ $# -gt 0 ] if [ $# -gt 0 ]
then then
c=$1 c="$1"
else else
c='=' c='='
fi fi
@ -289,7 +289,7 @@ set -- '.' "$@" -exec awk -v prefix="${filename_prefix}" "{print prefix ${ln} \$
print_verbose 2 "Using cache dir: ${cache_dir}" print_verbose 2 "Using cache dir: ${cache_dir}"
OLD_PWD=$(pwd) OLD_PWD=$(pwd)
cd "${cache_dir}" cd "${cache_dir}" || exit
# If no host is specified then search all. # If no host is specified then search all.
[ -z "${hosts}" ] && hosts="-" [ -z "${hosts}" ] && hosts="-"
@ -310,16 +310,16 @@ do
do do
dir=$(dirname "${d}") dir=$(dirname "${d}")
print_verbose 0 "target host: $(cat ${dir}/target_host), host directory: ${dir}" print_verbose 0 "target host: $(cat "${dir}/target_host"), host directory: ${dir}"
hor_line hor_line '='
PREV_PWD=$(pwd) PREV_PWD=$(pwd)
cd "${dir}" cd "${dir}" || exit
# set -x # set -x
find "$@" find "$@"
# set +x # set +x
cd "${PREV_PWD}" cd "${PREV_PWD}" || exit
done done
IFS="${OLD_IFS}" IFS="${OLD_IFS}"
done done
cd "${OLD_PWD}" cd "${OLD_PWD}" || exit