defer creating temp dir to when needed
set -e
-temp_dir=$(mktemp -d /tmp/xh.XXXXXXXX)
-trap 'rm -rf "$temp_dir"' EXIT INT TERM
-cd "$temp_dir"
-
if [ "$(uname -s)" = "Darwin" ] && [ "$(uname -m)" = "x86_64" ]; then
target="x86_64-apple-darwin"
elif [ "$(uname -s)" = "Linux" ] && [ "$(uname -m)" = "x86_64" ]; then
@@ -39,6 +35,10 @@ fi
echo "Downloading xh..."
+temp_dir=$(mktemp -d /tmp/xh.XXXXXXXX)
+trap 'rm -rf "$temp_dir"' EXIT INT TERM
+cd "$temp_dir"
+
if ! $fetch xh.tar.gz "$url"; then
echo "Could not download tarball"
exit 1
