aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/bootstrap/buildenv.sh
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2016-07-01 13:58:09 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-07-04 07:17:47 +0000
commitf47fd83ad044bb786883662380e4cf1f53c3cc63 (patch)
tree81b41d7c1fb8c614910d73009820834e45a75b3f /scripts/bootstrap/buildenv.sh
parentcc0180041dd1ef801b35ba28c1d34f19ffe22c95 (diff)
buildenv.sh: clean up each tmpdir once
...instead of cleaning up the last one once for each tmpdir. Commit 63e8d6321 changed the command registered atexit from an explict "rm -rf '${DIR}'" to a call to a cleanup_tempdir function, with the function containing the remove command. As, however, the function name is not unique (in fact, it is a constant), that function will get overridden at each invocation of the tempdir function. The fact that the function is registered several times with atexit doesn't help, as it will always remove the last created temporary directory. Fix this, by creating function names that encode the directory to be removed in the name. Fixes #1466. -- Change-Id: I833aef8ee5423412f058e74c8c9e2f4bb53a0cba Reviewed-on: https://bazel-review.googlesource.com/#/c/3955 MOS_MIGRATED_REVID=126406196
Diffstat (limited to 'scripts/bootstrap/buildenv.sh')
-rwxr-xr-xscripts/bootstrap/buildenv.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh
index 1ca2c710f6..6efa3556c8 100755
--- a/scripts/bootstrap/buildenv.sh
+++ b/scripts/bootstrap/buildenv.sh
@@ -99,8 +99,9 @@ function tempdir() {
local tmp=${TMPDIR:-/tmp}
local DIR="$(mktemp -d ${tmp%%/}/bazel.XXXXXXXX)"
mkdir -p "${DIR}"
- eval "cleanup_tempdir() { rm -rf '${DIR}'; }"
- atexit cleanup_tempdir
+ local DIRBASE=$(basename "${DIR}")
+ eval "cleanup_tempdir_${DIRBASE}() { rm -rf '${DIR}'; }"
+ atexit cleanup_tempdir_${DIRBASE}
NEW_TMPDIR="${DIR}"
}
tempdir