diff --git a/scripts/check-syntax.sh b/scripts/check-syntax.sh index f8195a4..4139fdf 100755 --- a/scripts/check-syntax.sh +++ b/scripts/check-syntax.sh @@ -54,6 +54,13 @@ find . -iname '*.sh' | while read -r script; do -e SC1004 \ "${script}" done +shellcheck -x \ + -e SC2002 \ + -e SC2126 \ + -e SC2129 \ + -e SC2181 \ + -e SC1004 \ + "tests-ng/helpers" # check other python scripts echo "-----------------------------------------" diff --git a/tests-ng/chmod-install.sh b/tests-ng/chmod-install.sh index e0b94e5..8075adc 100755 --- a/tests-ng/chmod-install.sh +++ b/tests-ng/chmod-install.sh @@ -267,7 +267,7 @@ chmod 600 "${tmps}"/dotfiles/nomode echo "nomode" > "${tmpd}"/nomode chmod 700 "${tmpd}"/nomode ( - d "${ddpath}" + cd "${ddpath}" printf 'y\ny\n' | ${bin} install -f -c "${cfg}" -p p2 -V f_nomode exit $? ) diff --git a/tests-ng/dynvariables.sh b/tests-ng/dynvariables.sh index c4ef62c..c537c4f 100755 --- a/tests-ng/dynvariables.sh +++ b/tests-ng/dynvariables.sh @@ -91,7 +91,7 @@ profiles: dotfiles: - f_abc _EOF -#cat ${cfg} +#cat "${cfg}" # create the dotfile echo "{{@@ var1 @@}}" > "${tmps}"/dotfiles/abc @@ -104,12 +104,13 @@ echo "test" >> "${tmps}"/dotfiles/abc # install cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1 -V +#cat "${cfg}" echo "-----" cat "${tmpd}"/abc echo "-----" grep '^this is some test' "${tmpd}"/abc >/dev/null -grep '^# author: deadc0de6' "${tmpd}"/abc >/dev/null +grep '^# shellcheck' "${tmpd}"/abc >/dev/null grep '^tset,emos,si,siht' "${tmpd}"/abc >/dev/null grep "^${TESTENV}" "${tmpd}"/abc > /dev/null grep '^4ravd_eht' "${tmpd}"/abc >/dev/null diff --git a/tests-ng/helpers b/tests-ng/helpers index 2876dfd..c7180da 100644 --- a/tests-ng/helpers +++ b/tests-ng/helpers @@ -1,3 +1,4 @@ +# shellcheck disable=SC2148 # author: deadc0de6 (https://github.com/deadc0de6) # Copyright (c) 2017, deadc0de6 # @@ -14,6 +15,7 @@ declare -a to_be_cleared clear_on_exit() { local len="${#to_be_cleared[*]}" + # shellcheck disable=SC2004 to_be_cleared[${len}]="$1" if [ "${len}" = "0" ]; then # set trap @@ -37,14 +39,16 @@ on_exit() create_dir() { dirs="a/aa a/ab a/ac b/ba c" - mkdir -p ${1} + mkdir -p "${1}" for d in ${dirs}; do # create some dirs - mkdir -p ${1}/${d} + mkdir -p "${1}"/"${d}" # create some files - fn=`echo ${d} | sed 's#/#-#g'` + # shellcheck disable=SC2001 + fn=$(echo "${d}" | sed 's#/#-#g') f="${1}/${d}/${fn}" - echo "${d}" > ${f} + echo "${d}" > "${f}" + # shellcheck disable=SC2034 token=${f} done } @@ -54,7 +58,7 @@ create_dir() # $1: path to save to create_conf() { - cat > ${1} << _EOF + cat > "${1}" << _EOF config: backup: true create: true diff --git a/tests-ng/profile-dynvariables.sh b/tests-ng/profile-dynvariables.sh index 2574a11..5f9522e 100755 --- a/tests-ng/profile-dynvariables.sh +++ b/tests-ng/profile-dynvariables.sh @@ -126,7 +126,7 @@ grep '^local1' "${tmpd}"/abc >/dev/null grep '^global2' "${tmpd}"/abc >/dev/null grep '^local2' "${tmpd}"/abc >/dev/null # test dynvariables -grep "^# author: deadc0de6" "${tmpd}"/abc >/dev/null +grep "^# shellcheck" "${tmpd}"/abc >/dev/null grep '^tset,emos,si,siht' "${tmpd}"/abc >/dev/null grep "^${TESTENV2}" "${tmpd}"/abc > /dev/null grep "^cba" "${tmpd}"/abc >/dev/null diff --git a/tests-ng/re-import.sh b/tests-ng/re-import.sh index 98fb149..c991763 100755 --- a/tests-ng/re-import.sh +++ b/tests-ng/re-import.sh @@ -122,9 +122,11 @@ cat "${cfg}" # ensure exists and is not link [ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1 -cat "${cfg}" | grep "${HOME}/.dotdrop.test" >/dev/null 2>&1 +# shellcheck disable=SC2088 +cat "${cfg}" | grep '~/.dotdrop.test' grep 'original' "${tmps}"/dotfiles/dotdrop.test -nb=$(cat "${cfg}" | grep "${HOME}/.dotdrop.test" | wc -l) +# shellcheck disable=SC2088 +nb=$(cat "${cfg}" | grep '~/.dotdrop.test' | wc -l) [ "${nb}" != "1" ] && echo 'not 1 entry' && exit 1 # re-import without changing @@ -134,9 +136,11 @@ cat "${cfg}" # test is only once [ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1 -cat "${cfg}" | grep "${HOME}/.dotdrop.test" >/dev/null 2>&1 +# shellcheck disable=SC2088 +cat "${cfg}" | grep '~/.dotdrop.test' >/dev/null 2>&1 grep 'original' "${tmps}"/dotfiles/dotdrop.test -nb=$(cat "${cfg}" | grep "${HOME}/.dotdrop.test" | wc -l) +# shellcheck disable=SC2088 +nb=$(cat "${cfg}" | grep '~/.dotdrop.test' | wc -l) [ "${nb}" != "1" ] && echo 'two entries!' && exit 1 # re-import with changes @@ -147,9 +151,11 @@ cat "${cfg}" # test is only once [ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1 -cat "${cfg}" | grep "${HOME}/.dotdrop.test" >/dev/null 2>&1 +# shellcheck disable=SC2088 +cat "${cfg}" | grep '~/.dotdrop.test' >/dev/null 2>&1 grep 'modified' "${tmps}"/dotfiles/dotdrop.test -nb=$(cat "${cfg}" | grep "${HOME}/.dotdrop.test" | wc -l) +# shellcheck disable=SC2088 +nb=$(cat "${cfg}" | grep '~/.dotdrop.test' | wc -l) [ "${nb}" != "1" ] && echo 'two entries!' && exit 1 echo "OK"