Skip to content

Commit 890fdbd

Browse files
committed
Harden Go OS/arch detection
1 parent fc9e6fb commit 890fdbd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/install_latest.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,13 @@ go_version_ok() {
208208

209209
go_os_arch() {
210210
local os arch
211-
os="$(uname -s)"
211+
os="$(uname -s 2>/dev/null | tr -d '\r' | xargs)" || return 1
212212
case "${os}" in
213213
Darwin) os="darwin" ;;
214214
Linux) os="linux" ;;
215215
*) return 1 ;;
216216
esac
217-
arch="$(uname -m)"
217+
arch="$(uname -m 2>/dev/null | tr -d '\r' | xargs)" || return 1
218218
case "${arch}" in
219219
x86_64|amd64) arch="amd64" ;;
220220
aarch64|arm64) arch="arm64" ;;
@@ -242,7 +242,7 @@ install_go_tarball() {
242242
ensure_sudo
243243

244244
local os arch tmp json_file info_file filename sha url actual
245-
read -r os arch < <(go_os_arch) || err "Unsupported OS/arch for Go install."
245+
read -r os arch < <(go_os_arch) || err "Unsupported OS/arch for Go install (expected darwin/linux + amd64/arm64)."
246246

247247
tmp="$(mktemp -d)"
248248
json_file="${tmp}/go.json"

0 commit comments

Comments
 (0)