Skip to content

Commit 58c49eb

Browse files
committed
support using curl to download files
Signed-off-by: Tin Lai <[email protected]>
1 parent bacd176 commit 58c49eb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

libexec/shsh-_post-gh-release

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ info_echo ">> Going to download release asset '$gh_release_asset'"
112112

113113
# We don't want the nested variables to expand
114114
# shellcheck disable=SC2016
115-
_script='wget '"$(echo "$item" | jq -r '.browser_download_url' | head -1)"' && '$unarchive_cmd' "$gh_release_asset"'
115+
_script='download '"$(echo "$item" | jq -r '.browser_download_url' | head -1)"' && '$unarchive_cmd' "$gh_release_asset"'
116116
execute_hooks "downloading gh-release" "$target_folder" "$_script"
117117

118118

libexec/shsh-_utils

+11-1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ gh_release_check_up_to_date() {
144144
return 0
145145
}
146146

147+
download() {
148+
if command_exists wget; then
149+
wget "$@"
150+
elif command_exists curl; then
151+
curl -LOJ "$@"
152+
else
153+
error_echo "No download tool found"
154+
exit 1
155+
fi
156+
}
147157
clear_prev_lines() {
148158
if [ -n "$SHSH_USE_TPUT" ]; then
149159
# clear all lines at once (ed clear from current to end of screen)
@@ -564,7 +574,7 @@ if ! command_exists jq; then
564574
# bootstrap jq
565575
if prompt ">> jq is needed but not found. Bootstrap by downloading a binary release?"; then
566576
set -e
567-
shsh install _bootstrap/jq --plain -h pre="wget https://github.com/stedolan/jq/releases/download/jq-1.6/$bin_name" -v BINS=''
577+
shsh install _bootstrap/jq --plain -h pre="download https://github.com/stedolan/jq/releases/download/jq-1.6/$bin_name" -v BINS=''
568578

569579
chmod +x "$SHSH_PACKAGES_PATH/_bootstrap/jq/$bin_name"
570580
else

0 commit comments

Comments
 (0)