Skip to content

Commit 117ca48

Browse files
committed
fix: refactor required command checks before tmp dir management
- Move the temp directory creation and cleanup logic after checking for required commands - Ensure mktemp is included in the list of required commands Signed-off-by: appleboy <[email protected]>
1 parent 58ed563 commit 117ca48

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

install.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
set -euo pipefail
44

5-
# Create temp directory for downloads.
6-
TMPDIR="$(mktemp -d)"
7-
function cleanup() {
8-
if [ -n "${TMPDIR:-}" ] && [ -d "$TMPDIR" ]; then
9-
rm -rf "$TMPDIR"
10-
fi
11-
}
12-
trap cleanup EXIT INT TERM
13-
145
APP=CodeGPT
156

167
RED='\033[0;31m'
@@ -114,12 +105,21 @@ function get_latest_version() {
114105
}
115106

116107
# Check for required commands
117-
for cmd in curl; do
108+
for cmd in curl mktemp; do
118109
if ! command -v "$cmd" >/dev/null 2>&1; then
119110
log_error "Error: $cmd is not installed. Please install $cmd to proceed." 1
120111
fi
121112
done
122113

114+
# Create temp directory for downloads.
115+
TMPDIR="$(mktemp -d)"
116+
function cleanup() {
117+
if [ -n "${TMPDIR:-}" ] && [ -d "$TMPDIR" ]; then
118+
rm -rf "$TMPDIR"
119+
fi
120+
}
121+
trap cleanup EXIT INT TERM
122+
123123
# If INSECURE is set to any value, enable curl --insecure
124124
INSECURE_ARG=""
125125
if [[ -n "${INSECURE:-}" ]]; then

0 commit comments

Comments
 (0)