Use TMPDIR environment variable in install script (#35636)

Anne Schuth created

## 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

Change summary

script/install.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Detailed changes

script/install.sh 🔗

@@ -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"