Skip to content

Commit

Permalink
Merge pull request #211 from tegonal/bugfix/trap-SIGINT
Browse files Browse the repository at this point in the history
don't set a trap for SIGINT (EXIT trap is still called)
  • Loading branch information
robstoll authored Oct 24, 2024
2 parents 7cfb63d + 10059e5 commit dd738e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/gt-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ sourceOnce "$dir_of_tegonal_scripts/utility/io.sh"
sourceOnce "$dir_of_tegonal_scripts/utility/parse-args.sh"

function gt_pull_cleanupRepo() {
# note, we want to cleanup also for normal exits, so no need to check for $?
local -r repository=$1
if [[ -d $repository ]]; then
find "$repository" -maxdepth 1 -type d -not -path "$repository" -not -name ".git" -exec rm -r {} \;
Expand Down Expand Up @@ -266,7 +267,7 @@ function gt_pull() {

# we want to expand $repo here and not when signal happens (as $repo might be out of scope)
# shellcheck disable=SC2064
trap "gt_pull_cleanupRepo '$repo'" EXIT SIGINT
trap "gt_pull_cleanupRepo '$repo'" EXIT

askToDeleteAndReInitialiseGitDirIfRemoteIsBroken "$workingDirAbsolute" "$remote"

Expand Down
11 changes: 5 additions & 6 deletions src/gt-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ function gt_remote_cleanupRemoteOnUnexpectedExit() {
local -r result=$?

local -r remoteDir=$1
local -r currentDir=$2
shift 2 || traceAndDie "could not shift by 2"

if ! ((result == 0)) && [[ -d $remoteDir ]]; then
# delete the remoteDir and its content
deleteDirChmod777 "$remoteDir"
if [[ -d $remoteDir ]]; then
# delete the remoteDir and its content
deleteDirChmod777 "$remoteDir"
fi
# re-add so that one can still establish trust manually
mkdir "$remoteDir"
fi
Expand Down Expand Up @@ -162,7 +161,7 @@ function gt_remote_add() {

# we want to expand $remoteDir and $currentDir here and not when signal happens (as they might be out of scope)
# shellcheck disable=SC2064
trap "gt_remote_cleanupRemoteOnUnexpectedExit '$remoteDir' '$currentDir'" EXIT SIGINT
trap "gt_remote_cleanupRemoteOnUnexpectedExit '$remoteDir'" EXIT

echo "$pullDirParamPatternLong \"$pullDir\"" >"$pullArgsFile" || logWarningCouldNotWritePullArgs "the pull directory" "$pullDir" "$pullArgsFile" "$pullDirParamPatternLong" "$remote"

Expand Down

0 comments on commit dd738e2

Please sign in to comment.