Use TMPDIR environment variable in install script (#35636)

## Summary
This PR updates the install script to respect the `TMPDIR` environment
variable when creating temporary directories.

## Motivation
Some environments have non-standard temporary directory locations or
restrictions on `/tmp`. This change allows users to specify an
alternative temporary directory by setting the `TMPDIR` environment
variable.

## Changes
- Check if `TMPDIR` is set and points to a valid directory
- Use `$TMPDIR` for temporary files if available
- Fall back to `/tmp` if `TMPDIR` is not set or invalid

## Testing
Tested the script with:
- `TMPDIR` unset (uses `/tmp` as before)
- `TMPDIR` set to a valid directory (uses specified directory)
- `TMPDIR` set to an invalid path (falls back to `/tmp`)

This change maintains backward compatibility while adding flexibility
for environments with non-standard temporary directory requirements.

Release Notes:

- N/A
This commit is contained in:
Anne Schuth 2025-08-08 07:05:56 +02:00 committed by GitHub
parent 2c7251e4f9
commit 3bee803b51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,7 +9,12 @@ main() {
platform="$(uname -s)"
arch="$(uname -m)"
channel="${ZED_CHANNEL:-stable}"
temp="$(mktemp -d "/tmp/zed-XXXXXX")"
# Use TMPDIR if available (for environments with non-standard temp directories)
if [ -n "${TMPDIR:-}" ] && [ -d "${TMPDIR}" ]; then
temp="$(mktemp -d "$TMPDIR/zed-XXXXXX")"
else
temp="$(mktemp -d "/tmp/zed-XXXXXX")"
fi
if [ "$platform" = "Darwin" ]; then
platform="macos"