♻️ refactor(shortcuts): 安全地在临时目录中创建临时脚本文件

This commit is contained in:
2026-06-08 10:15:32 +08:00
parent 5d9f8120a5
commit afc8c70b95
2 changed files with 7 additions and 5 deletions
+4 -3
View File
@@ -5,10 +5,11 @@
set -euo pipefail
REMOTE="${VM_FIXER_REMOTE:-https://git.orionc.me/orion/script/raw/branch/main/shortcuts/vm-permission-fixer.sh}"
TEMP="$(mktemp "${TMPDIR:-/tmp}/vm-permission-fixer.XXXXXX.sh")"
TEMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/vm-permission-fixer.XXXXXX")"
TEMP="${TEMP_DIR}/vm-permission-fixer.sh"
cleanup() {
rm -f "$TEMP"
rm -rf "$TEMP_DIR"
}
trap cleanup EXIT INT TERM
@@ -29,4 +30,4 @@ if [[ -n "${VM_FIXER_SHA256:-}" ]]; then
fi
fi
exec /usr/bin/env bash "$TEMP" "$@"
/usr/bin/env bash "$TEMP" "$@"