Skip to content

Commit 42df2d4

Browse files
committed
fix(install): check the qualified formula; download the dist installer before running it
1 parent 53ef1e6 commit 42df2d4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎scripts/install.sh‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fi
5757

5858
if [ -n "$BREW" ]; then
5959
echo "Homebrew found at $BREW; installing $FORMULA" >&2
60-
if "$BREW" list --formula cli >/dev/null 2>&1; then
60+
if "$BREW" list --formula "$FORMULA" >/dev/null 2>&1; then
6161
"$BREW" upgrade "$FORMULA"
6262
else
6363
"$BREW" install "$FORMULA"
@@ -69,12 +69,17 @@ if [ -n "$BREW" ]; then
6969
fi
7070

7171
echo "Homebrew not found; installing a prebuilt binary to ~/.hotdata/cli" >&2
72+
# Download fully before running: plain sh has no pipefail, so a failed
73+
# download piped into sh would otherwise "succeed" with nothing installed.
74+
TMP="$(mktemp)"
75+
trap 'rm -f "$TMP"' EXIT
7276
if command -v curl >/dev/null 2>&1; then
73-
curl --proto '=https' --tlsv1.2 -LsSf "$DIST_INSTALLER" | sh
77+
curl --proto '=https' --tlsv1.2 -LsSf "$DIST_INSTALLER" -o "$TMP"
7478
elif command -v wget >/dev/null 2>&1; then
75-
wget -qO- "$DIST_INSTALLER" | sh
79+
wget -qO "$TMP" "$DIST_INSTALLER"
7680
else
7781
echo "error: need curl or wget to download the installer" >&2
7882
exit 1
7983
fi
84+
sh "$TMP"
8085
install_skills "$HOME/.hotdata/cli/hotdata"

0 commit comments

Comments
 (0)