1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-09 21:04: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

@@ -33,7 +33,9 @@ ddpath="${cur}/../"
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}"
@@ -41,7 +43,7 @@ echo "pythonpath: ${PYTHONPATH}"
# get the 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
@@ -54,31 +56,31 @@ has_rights()
echo "testing ${1} is ${2}"
[ ! -e "$1" ] && echo "`basename $1` does not exist" && exit 1
local mode=`stat -L -c '%a' "$1"`
[ "${mode}" != "$2" ] && echo "bad mode for `basename $1` (${mode} VS expected ${2})" && exit 1
[ "${mode}" != "$2" ] && echo "bad mode for `basename "$1"` (${mode} VS expected ${2})" && exit 1
true
}
get_file_mode()
{
u=`umask`
u=`echo ${u} | sed 's/^0*//'`
u=$(umask)
u=$(echo "${u}" | sed 's/^0*//')
v=$((666 - u))
echo "${v}"
}
get_dir_mode()
{
u=`umask`
u=`echo ${u} | sed 's/^0*//'`
u=$(umask)
u=$(echo "${u}" | sed 's/^0*//')
v=$((777 - u))
echo "${v}"
}
# 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}"
@@ -87,42 +89,42 @@ clear_on_exit "${tmpd}"
# create the config file
cfg="${tmps}/config.yaml"
echo 'f777' > ${tmps}/dotfiles/f777
chmod 700 ${tmps}/dotfiles/f777
echo 'link' > ${tmps}/dotfiles/link
chmod 777 ${tmps}/dotfiles/link
mkdir -p ${tmps}/dotfiles/dir
echo "f1" > ${tmps}/dotfiles/dir/f1
echo 'f777' > "${tmps}"/dotfiles/f777
chmod 700 "${tmps}"/dotfiles/f777
echo 'link' > "${tmps}"/dotfiles/link
chmod 777 "${tmps}"/dotfiles/link
mkdir -p "${tmps}"/dotfiles/dir
echo "f1" > "${tmps}"/dotfiles/dir/f1
echo "exists" > ${tmps}/dotfiles/exists
chmod 644 ${tmps}/dotfiles/exists
echo "exists" > ${tmpd}/exists
chmod 644 ${tmpd}/exists
echo "exists" > "${tmps}"/dotfiles/exists
chmod 644 "${tmps}"/dotfiles/exists
echo "exists" > "${tmpd}"/exists
chmod 644 "${tmpd}"/exists
echo "existslink" > ${tmps}/dotfiles/existslink
chmod 777 ${tmps}/dotfiles/existslink
chmod 644 ${tmpd}/exists
echo "existslink" > "${tmps}"/dotfiles/existslink
chmod 777 "${tmps}"/dotfiles/existslink
chmod 644 "${tmpd}"/exists
mkdir -p ${tmps}/dotfiles/direxists
echo "f1" > ${tmps}/dotfiles/direxists/f1
mkdir -p ${tmpd}/direxists
echo "f1" > ${tmpd}/direxists/f1
chmod 644 ${tmpd}/direxists/f1
chmod 744 ${tmpd}/direxists
mkdir -p "${tmps}"/dotfiles/direxists
echo "f1" > "${tmps}"/dotfiles/direxists/f1
mkdir -p "${tmpd}"/direxists
echo "f1" > "${tmpd}"/direxists/f1
chmod 644 "${tmpd}"/direxists/f1
chmod 744 "${tmpd}"/direxists
mkdir -p ${tmps}/dotfiles/linkchildren
echo "f1" > ${tmps}/dotfiles/linkchildren/f1
mkdir -p ${tmps}/dotfiles/linkchildren/d1
echo "f2" > ${tmps}/dotfiles/linkchildren/d1/f2
mkdir -p "${tmps}"/dotfiles/linkchildren
echo "f1" > "${tmps}"/dotfiles/linkchildren/f1
mkdir -p "${tmps}"/dotfiles/linkchildren/d1
echo "f2" > "${tmps}"/dotfiles/linkchildren/d1/f2
echo '{{@@ profile @@}}' > ${tmps}/dotfiles/symlinktemplate
echo '{{@@ profile @@}}' > "${tmps}"/dotfiles/symlinktemplate
mkdir -p ${tmps}/dotfiles/symlinktemplatedir
echo "{{@@ profile @@}}" > ${tmps}/dotfiles/symlinktemplatedir/t
mkdir -p "${tmps}"/dotfiles/symlinktemplatedir
echo "{{@@ profile @@}}" > "${tmps}"/dotfiles/symlinktemplatedir/t
echo 'nomode' > ${tmps}/dotfiles/nomode
echo 'nomode' > "${tmps}"/dotfiles/nomode
cat > ${cfg} << _EOF
cat > "${cfg}" << _EOF
config:
backup: true
create: true
@@ -197,7 +199,7 @@ _EOF
# install
echo "first install round"
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p1 -V
echo "first install round"
has_rights "${tmpd}/f777" "777"
@@ -212,24 +214,24 @@ has_rights "${tmpd}/linkchildren/f1" "644"
has_rights "${tmpd}/linkchildren/d1" "755"
has_rights "${tmpd}/linkchildren/d1/f2" "644"
has_rights "${tmpd}/symlinktemplate" "777"
m=`get_file_mode`
m=$(get_file_mode)
has_rights "${tmpd}/nomode" "${m}"
grep 'p1' ${tmpd}/symlinktemplate
grep 'p1' ${tmpd}/symlinktemplatedir/t
grep 'p1' "${tmpd}"/symlinktemplate
grep 'p1' "${tmpd}"/symlinktemplatedir/t
## second round
echo "exists" > ${tmps}/dotfiles/exists
chmod 600 ${tmps}/dotfiles/exists
echo "exists" > ${tmpd}/exists
chmod 600 ${tmpd}/exists
echo "exists" > "${tmps}"/dotfiles/exists
chmod 600 "${tmps}"/dotfiles/exists
echo "exists" > "${tmpd}"/exists
chmod 600 "${tmpd}"/exists
chmod 700 ${tmpd}/linkchildren
chmod 700 "${tmpd}"/linkchildren
chmod 600 ${tmpd}/symlinktemplate
chmod 600 "${tmpd}"/symlinktemplate
echo "second install round"
cd ${ddpath} | ${bin} install -c ${cfg} -p p2 -f -V
cd "${ddpath}" | ${bin} install -c "${cfg}" -p p2 -f -V
echo "second install round"
has_rights "${tmpd}/exists" "777"
@@ -237,39 +239,39 @@ has_rights "${tmpd}/linkchildren/f1" "644"
has_rights "${tmpd}/linkchildren/d1" "755"
has_rights "${tmpd}/linkchildren/d1/f2" "644"
has_rights "${tmpd}/symlinktemplate" "777"
m=`get_file_mode`
m=$(get_file_mode)
has_rights "${tmpd}/nomode" "${m}"
## no user confirmation expected
## same mode
echo "same mode"
echo "nomode" > ${tmps}/dotfiles/nomode
chmod 600 ${tmps}/dotfiles/nomode
echo "nomode" > ${tmpd}/nomode
chmod 600 ${tmpd}/nomode
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p2 -V f_nomode
echo "nomode" > "${tmps}"/dotfiles/nomode
chmod 600 "${tmps}"/dotfiles/nomode
echo "nomode" > "${tmpd}"/nomode
chmod 600 "${tmpd}"/nomode
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p2 -V f_nomode
echo "same mode"
has_rights "${tmpd}/nomode" "600"
## no user confirmation with force
## different mode
echo "different mode"
echo "nomode" > ${tmps}/dotfiles/nomode
chmod 600 ${tmps}/dotfiles/nomode
echo "nomode" > ${tmpd}/nomode
chmod 700 ${tmpd}/nomode
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p2 -V f_nomode
echo "nomode" > "${tmps}"/dotfiles/nomode
chmod 600 "${tmps}"/dotfiles/nomode
echo "nomode" > "${tmpd}"/nomode
chmod 700 "${tmpd}"/nomode
cd "${ddpath}" | ${bin} install -c "${cfg}" -f -p p2 -V f_nomode
echo "different mode (1)"
has_rights "${tmpd}/nomode" "600"
## user confirmation expected
## different mode
echo "different mode"
echo "nomode" > ${tmps}/dotfiles/nomode
chmod 600 ${tmps}/dotfiles/nomode
echo "nomode" > ${tmpd}/nomode
chmod 700 ${tmpd}/nomode
cd ${ddpath} | printf 'y\ny\n' | ${bin} install -f -c ${cfg} -p p2 -V f_nomode
echo "nomode" > "${tmps}"/dotfiles/nomode
chmod 600 "${tmps}"/dotfiles/nomode
echo "nomode" > "${tmpd}"/nomode
chmod 700 "${tmpd}"/nomode
cd "${ddpath}" | printf 'y\ny\n' | ${bin} install -f -c "${cfg}" -p p2 -V f_nomode
echo "different mode (2)"
has_rights "${tmpd}/nomode" "600"