diff --git a/42git.sh b/42git.sh index 41895da..25db61c 100755 --- a/42git.sh +++ b/42git.sh @@ -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"