1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-11 07:54:15 +00:00

shellcheck fixes

This commit is contained in:
deadc0de6
2023-01-27 16:44:19 +01:00
committed by deadc0de
parent fd26eb89b3
commit 2f1bbeacee
135 changed files with 4083 additions and 3950 deletions

View File

@@ -27,29 +27,32 @@ cur=$(dirname "$(${rl} "${0}")")
# dotdrop path can be pass as argument
ddpath="${cur}/../"
[ "${1}" != "" ] && ddpath="${1}"
[ ! -d ${ddpath} ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
[ ! -d "${ddpath}" ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
bin="python3 -m dotdrop.dotdrop"
hash coverage 2>/dev/null && bin="coverage run -a --source=dotdrop -m dotdrop.dotdrop" || true
if hash coverage 2>/dev/null; then
bin="coverage run -a --source=dotdrop -m dotdrop.dotdrop"
fi
echo "dotdrop path: ${ddpath}"
echo "pythonpath: ${PYTHONPATH}"
# get the helpers
source ${cur}/helpers
# shellcheck source=tests-ng/helpers
source "${cur}"/helpers
echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
echo -e "$(tput setaf 6)==> RUNNING $(basename "${BASH_SOURCE[0]}") <==$(tput sgr0)"
################################################################
# this is the test
################################################################
# the dotfile source
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
mkdir -p ${tmps}/dotfiles
tmps=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
mkdir -p "${tmps}"/dotfiles
# the dotfile destination
tmpd=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
#echo "dotfile destination: ${tmpd}"
clear_on_exit "${tmps}"
@@ -57,40 +60,40 @@ clear_on_exit "${tmpd}"
# create the dotfile
dnormal="${tmpd}/dir_normal"
mkdir -p ${dnormal}
echo "dir_normal/f1" > ${dnormal}/file1
echo "dir_normal/f2" > ${dnormal}/file2
chmod 777 ${dnormal}
mkdir -p "${dnormal}"
echo "dir_normal/f1" > "${dnormal}"/file1
echo "dir_normal/f2" > "${dnormal}"/file2
chmod 777 "${dnormal}"
dlink="${tmpd}/dir_link"
mkdir -p ${dlink}
echo "dir_link/f1" > ${dlink}/file1
echo "dir_link/f2" > ${dlink}/file2
chmod 777 ${dlink}
mkdir -p "${dlink}"
echo "dir_link/f1" > "${dlink}"/file1
echo "dir_link/f2" > "${dlink}"/file2
chmod 777 "${dlink}"
dlinkchildren="${tmpd}/dir_link_children"
mkdir -p ${dlinkchildren}
echo "dir_linkchildren/f1" > ${dlinkchildren}/file1
echo "dir_linkchildren/f2" > ${dlinkchildren}/file2
chmod 777 ${dlinkchildren}
mkdir -p "${dlinkchildren}"
echo "dir_linkchildren/f1" > "${dlinkchildren}"/file1
echo "dir_linkchildren/f2" > "${dlinkchildren}"/file2
chmod 777 "${dlinkchildren}"
fnormal="${tmpd}/filenormal"
echo "filenormal" > ${fnormal}
chmod 777 ${fnormal}
echo "filenormal" > "${fnormal}"
chmod 777 "${fnormal}"
flink="${tmpd}/filelink"
echo "filelink" > ${flink}
chmod 777 ${flink}
echo "filelink" > "${flink}"
chmod 777 "${flink}"
echo "f777" > ${tmps}/dotfiles/f777
chmod 700 ${tmps}/dotfiles/f777
echo "f777" > "${tmps}"/dotfiles/f777
chmod 700 "${tmps}"/dotfiles/f777
toimport="${dnormal} ${dlink} ${dlinkchildren} ${fnormal} ${flink}"
# create the config file
cfg="${tmps}/config.yaml"
cat > ${cfg} << _EOF
cat > "${cfg}" << _EOF
config:
backup: true
create: true
@@ -108,27 +111,27 @@ _EOF
#cat ${cfg}
# install
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1
cd "${ddpath}" | ${bin} install -f -c "${cfg}" -p p1
# compare
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1
cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1
# import
for i in ${toimport}; do
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 ${i}
cd "${ddpath}" | ${bin} import -c "${cfg}" -f -p p1 "${i}"
done
#cat ${cfg}
# patch rights
chmod 700 ${dnormal}
chmod 700 ${dlink}
chmod 700 ${dlinkchildren}
chmod 700 ${fnormal}
chmod 700 ${flink}
chmod 700 "${dnormal}"
chmod 700 "${dlink}"
chmod 700 "${dlinkchildren}"
chmod 700 "${fnormal}"
chmod 700 "${flink}"
set +e
out=`cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 2>&1`
out=$(cd "${ddpath}" | ${bin} compare -c "${cfg}" -p p1 2>&1)
cnt=$(echo "${out}" | grep 'modes differ' | wc -l)
set -e
[ "${cnt}" != "5" ] && echo "${out}" && echo "compare modes failed (${cnt}, expecting 5)" && exit 1