Skip to content

Commit

Permalink
fix strict bash pipefail
Browse files Browse the repository at this point in the history
  • Loading branch information
deadc0de6 committed Nov 9, 2023
1 parent 7bd1d7f commit 94d97bf
Show file tree
Hide file tree
Showing 152 changed files with 166 additions and 162 deletions.
2 changes: 1 addition & 1 deletion completion/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# pip3 install --user infi.docopt_completion
#

set -euo errtrace pipefail
set -eu -o errtrace -o pipefail

bin="docopt-completion"
if ! hash ${bin}; then
Expand Down
8 changes: 4 additions & 4 deletions dotdrop/dotfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,23 @@ def prt(self):
some = self.get_pre_actions()
if some:
for act in some:
out += f'\n{2*indent}- {act}'
out += f'\n{2 * indent}- {act}'

out += f'\n{indent}post-action:'
some = self.get_post_actions()
if some:
for act in some:
out += f'\n{2*indent}- {act}'
out += f'\n{2 * indent}- {act}'

out += f'\n{indent}trans_install:'
some = self.get_trans_install()
if some:
out += f'\n{2*indent}- {some}'
out += f'\n{2 * indent}- {some}'

out += f'\n{indent}trans_update:'
some = self.get_trans_update()
if some:
out += f'\n{2*indent}- {some}'
out += f'\n{2 * indent}- {some}'
return out

def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2022, deadc0de6

# stop on first error
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail

## test doc external links
echo "------------------------"
Expand Down
5 changes: 3 additions & 2 deletions scripts/check-syntax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2022, deadc0de6

# stop on first error
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail

# ensure binaries are here
if ! which shellcheck >/dev/null 2>&1; then
Expand Down Expand Up @@ -50,7 +50,8 @@ echo "---------------------------------"
echo "checking for bash strict mode"
find tests-ng -iname '*.sh' | while read -r script; do
#grep 'set +e' "${script}" 2>&1 >/dev/null && echo "set +e found in ${script}" && exit 1
grep 'set -euo errtrace pipefail' "${script}" >/dev/null 2>&1 || (echo "set -euo errtrace pipefail not set in ${script}" && exit 1 )
grep 'set -eu -o errtrace -o pipefail' "${script}" >/dev/null 2>&1 || \
(echo "\"set -eu -o errtrace -o pipefail\" not set in ${script}" && exit 1 )
done

# PEP8 tests
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-tests-ng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2023, deadc0de6

# stop on first error
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail

tmpworkdir="/tmp/dotdrop-tests-workdir"
export DOTDROP_WORKDIR="${tmpworkdir}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-unittests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2023, deadc0de6

# stop on first error
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail

WORKERS=${DOTDROP_WORKERS:-}
if [ -n "${WORKERS}" ]; then
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/actions-args-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/actions-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/actions-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/actions-empty-dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/actions-pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/actions-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/bad-diff-cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/chmod-compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
4 changes: 2 additions & 2 deletions tests-ng/chmod-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down Expand Up @@ -194,7 +194,7 @@ cat "${cfg}"
# list files
cd "${ddpath}" | ${bin} detail -c "${cfg}" -p p1 -V

cnt=$(cat "${cfg}" | grep chmod | wc -l)
cnt=$(cat "${cfg}" | (grep chmod || :) | wc -l)
[ "${cnt}" != "0" ] && echo "chmod inserted but not needed" && exit 1

## with config option chmod_on_import
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/chmod-install-dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/chmod-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/chmod-more.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/chmod-preserve-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
12 changes: 8 additions & 4 deletions tests-ng/chmod-preserve-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down Expand Up @@ -120,15 +120,19 @@ profiles:
_EOF
#cat ${cfg}

echo "update"
echo "update1"
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/exists
echo "update2"
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/existslink
echo "update3"
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/direxists
echo "update4"
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/linkchildren
echo "update5"
cd "${ddpath}" | ${bin} update -f -c "${cfg}" -p p1 -V "${tmpd}"/nomode

count=$(cat "${cfg}" | grep chmod | grep -v 'chmod: preserve\|force_chmod' | wc -l)
echo "${count}"
count=$(grep chmod "${cfg}" | (grep -v 'preserve\|force_chmod' || :) | wc -l)
echo "chmod changed: ${count}"
[ "${count}" != "0" ] && echo "chmod altered" && exit 1

echo "OK"
Expand Down
4 changes: 2 additions & 2 deletions tests-ng/chmod-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down Expand Up @@ -80,7 +80,7 @@ done
cat "${cfg}"

# test no chmod
cnt=$(cat "${cfg}" | grep chmod | wc -l)
cnt=$(cat "${cfg}" | ( grep chmod || : ) | wc -l)
[ "${cnt}" != "0" ] && echo "chmod wrongly inserted" && exit 1

######################
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/clear-workdir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-diff-types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-global-negative-ignore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-ignore-in-dotpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-ignore-missing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-ignore-relative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-ignore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-negative-ignore-all-but.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-negative-ignore-relative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-negative-ignore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

# exit on first error
#set -euo errtrace pipefail
#set -eu -o errtrace -o pipefail

cur=$(cd "$(dirname "${0}")" && pwd)

Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare-profile-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
2 changes: 1 addition & 1 deletion tests-ng/compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

## start-cookie
set -euo errtrace pipefail
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
ddpath="${cur}/../"
PPATH="{PYTHONPATH:-}"
Expand Down
Loading

0 comments on commit 94d97bf

Please sign in to comment.