File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,29 @@ set_install_dir() {
218218 fi
219219}
220220
221+ #
222+ # @param $1: 下载链接
223+ # @param $2: 保存路径(带文件名)
224+ #
225+ download () {
226+ if command -v curl & > /dev/null; then
227+ curl -sL " $1 " -o " $2 "
228+ return $? # 只能单独 return
229+ fi
230+
231+ if command -v wget & > /dev/null; then
232+ # follow 是wget默认行为
233+ wget -qO " $2 " " $1 "
234+ return $?
235+ fi
236+
237+ if [ " $userOpt_lang " = " zh" ]; then
238+ error " 缺乏必要的下载工具(curl或wget),无法下载文件"
239+ else
240+ error " Missing necessary download tools (curl or wget) to download the file!"
241+ fi
242+ }
243+
221244
222245install () {
223246
@@ -239,11 +262,13 @@ install() {
239262 info " Downloading ${binary_name} (arch: ${arch} , platform: ${platform} , version: ${binary_version} ) to ${path_to_executable} "
240263 fi
241264
242- if curl -sL " $url " -o " $path_to_executable " ; then
265+ download $url " $path_to_executable "
266+
267+ if $? ; then
243268 chmod +x " $path_to_executable "
244269
245270 if [ " $userOpt_lang " = " zh" ]; then
246- info " 🎉 安装完成,a版本: $binary_version , 路径: $path_to_executable "
271+ info " 🎉 安装完成,路径: $path_to_executable "
247272 else
248273 info " 🎉 Installation completed, path: $path_to_executable "
249274 fi
You can’t perform that action at this time.
0 commit comments