Preserve original TMPDIR value when setting temporary directory

Improve git_clone_scripts to save and restore the original TMPDIR value instead of unconditionally unsetting it, avoiding unintended side effects.

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-03 06:56:08 +00:00
parent 7deab5d18e
commit 60f8286825

View File

@ -259,10 +259,15 @@ git_clone_scripts() {
set_proxy "$proxy"
# Set TMPDIR to /tmp to avoid "unable to get random bytes" error in some Docker environments
local original_tmpdir="${TMPDIR:-}"
export TMPDIR=/tmp
git clone -q --depth=1 $part_cmd $url $dir
exit_status=$?
if [[ -n "$original_tmpdir" ]]; then
export TMPDIR="$original_tmpdir"
else
unset TMPDIR
fi
unset_proxy
}