proper cleanup trap

This commit is contained in:
daniel fusser 2023-03-21 21:41:13 +01:00
parent 48e6a13ba9
commit 4b18880089

View File

@ -12,7 +12,13 @@ git_repo="git@git.dafu.dev:3022/dafu/fg_backup"
# temp dir
temp_dir=$(mktemp -d)
cd "$temp_dir"
cd "$temp_dir" || exit
cleanup() {
rm -r "$temp_dir"
}
trap cleanup EXIT
# git
echo "cloning from $git_repo"
@ -57,5 +63,3 @@ else
echo "no changes found. aborting"
fi
# cleanup
rm -r "$temp_dir"