From 4b188800899cdc7d0923ae1116c787cd3d49add0 Mon Sep 17 00:00:00 2001 From: daniel fusser Date: Tue, 21 Mar 2023 21:41:13 +0100 Subject: [PATCH] proper cleanup trap --- 42git.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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"