Merge pull request #179896 from erikarvstedt/fix-bash-exit-handler
treewide: fix bash exit handlers
This commit is contained in:
commit
10a745eac8
6 changed files with 10 additions and 19 deletions
|
@ -35,7 +35,7 @@ toRemove=()
|
|||
cleanup() {
|
||||
rm -rf "${toRemove[@]}"
|
||||
}
|
||||
trap cleanup EXIT SIGINT SIGQUIT ERR
|
||||
trap cleanup EXIT
|
||||
|
||||
MKTEMP='mktemp --tmpdir nix-rebuild-amount-XXXXXXXX'
|
||||
|
||||
|
|
|
@ -23,12 +23,10 @@ let
|
|||
on_exit()
|
||||
{
|
||||
exitStatus=$?
|
||||
# Reset the EXIT handler, or else we're called again on 'exit' below
|
||||
trap - EXIT
|
||||
${cfg.postHook}
|
||||
exit $exitStatus
|
||||
}
|
||||
trap 'on_exit' INT TERM QUIT EXIT
|
||||
trap on_exit EXIT
|
||||
|
||||
archiveName="${if cfg.archiveBaseName == null then "" else cfg.archiveBaseName + "-"}$(date ${cfg.dateFormat})"
|
||||
archiveSuffix="${optionalString cfg.appendFailedSuffix ".failed"}"
|
||||
|
|
|
@ -562,7 +562,7 @@ in
|
|||
shopt -s inherit_errexit
|
||||
|
||||
create_role="$(mktemp)"
|
||||
trap 'rm -f "$create_role"' ERR EXIT
|
||||
trap 'rm -f "$create_role"' EXIT
|
||||
|
||||
db_password="$(<"$CREDENTIALS_DIRECTORY/db_password")"
|
||||
echo "CREATE ROLE keycloak WITH LOGIN PASSWORD '$db_password' CREATEDB" > "$create_role"
|
||||
|
|
|
@ -37,14 +37,12 @@ prefetchExtensionUnpacked() {
|
|||
1>&2 echo "zipStorePath='$zipStorePath'"
|
||||
|
||||
function rm_tmpdir() {
|
||||
1>&2 printf "rm -rf -- %q\n" "$tmpDir"
|
||||
rm -rf -- "$tmpDir"
|
||||
unset tmpDir
|
||||
trap - INT TERM HUP EXIT
|
||||
1>&2 printf "rm -rf %q\n" "$tmpDir"
|
||||
rm -rf "$tmpDir"
|
||||
}
|
||||
function make_trapped_tmpdir() {
|
||||
tmpDir=$(mktemp -d)
|
||||
trap rm_tmpdir INT TERM HUP EXIT
|
||||
trap rm_tmpdir EXIT
|
||||
}
|
||||
|
||||
1>&2 echo
|
||||
|
|
|
@ -44,14 +44,11 @@ extStoreName="${extPublisher}-${extName}"
|
|||
|
||||
|
||||
function rm_tmpdir() {
|
||||
#echo "Removing \`tmpDir='$tmpDir'\`"
|
||||
rm -rf -- "$tmpDir"
|
||||
unset tmpDir
|
||||
trap - INT TERM HUP EXIT
|
||||
rm -rf "$tmpDir"
|
||||
}
|
||||
function make_trapped_tmpdir() {
|
||||
tmpDir=$(mktemp -d)
|
||||
trap rm_tmpdir INT TERM HUP EXIT
|
||||
trap rm_tmpdir EXIT
|
||||
}
|
||||
|
||||
echo
|
||||
|
|
|
@ -21,13 +21,11 @@ fi
|
|||
|
||||
mkTempDir() {
|
||||
tmpPath="$(mktemp -d "${TMPDIR:-/tmp}/nix-prefetch-cvs-XXXXXXXX")"
|
||||
trap removeTempDir EXIT SIGINT SIGQUIT
|
||||
trap removeTempDir EXIT
|
||||
}
|
||||
|
||||
removeTempDir() {
|
||||
if test -n "$tmpPath"; then
|
||||
rm -rf "$tmpPath" || true
|
||||
fi
|
||||
rm -rf "$tmpPath"
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue