mirror of
https://github.com/RubyMetric/chsrc.git
synced 2025-02-02 07:03:16 +08:00
<add>: add readable comments on script func.
This commit is contained in:
parent
3f0e7fa78d
commit
9db18d2b04
|
@ -19,15 +19,18 @@ default_install_path="/usr/local/bin"
|
||||||
binary_name="chsrc"
|
binary_name="chsrc"
|
||||||
temp_install_dir="" # 用于存储临时安装目录
|
temp_install_dir="" # 用于存储临时安装目录
|
||||||
|
|
||||||
|
# 输出相关信息
|
||||||
info() {
|
info() {
|
||||||
echo "[INFO] $*"
|
echo "[INFO] $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 输出错误到stdout和stderr
|
||||||
error() {
|
error() {
|
||||||
echo -e "[ERROR] $*" >&2
|
echo -e "[ERROR] $*" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 显示 chsrc 安装程序的帮助信息,包括使用说明和可用选项
|
||||||
help() {
|
help() {
|
||||||
echo "chsrc Installer"
|
echo "chsrc Installer"
|
||||||
echo
|
echo
|
||||||
|
@ -39,6 +42,7 @@ help() {
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 确定下载路径
|
||||||
set_install_path() {
|
set_install_path() {
|
||||||
if [ -n "$install_dir" ]; then
|
if [ -n "$install_dir" ]; then
|
||||||
# 扩展 ~ 符号
|
# 扩展 ~ 符号
|
||||||
|
@ -63,6 +67,7 @@ set_install_path() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 从Gitee仓库安装 指定架构,操作系统,版本 的chsrc二进制文件
|
||||||
install() {
|
install() {
|
||||||
arch="$(uname -m | tr '[:upper:]' '[:lower:]')"
|
arch="$(uname -m | tr '[:upper:]' '[:lower:]')"
|
||||||
|
|
||||||
|
@ -112,7 +117,7 @@ cleanup() {
|
||||||
# 设置 trap 以捕获退出信号
|
# 设置 trap 以捕获退出信号
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
# main
|
# 从命令行读取 安装路径与版本号
|
||||||
while getopts ":hd:v:" option; do
|
while getopts ":hd:v:" option; do
|
||||||
case $option in
|
case $option in
|
||||||
h)
|
h)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user