Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update install-release.sh #1511

Closed
wants to merge 4 commits into from
Closed

update install-release.sh #1511

wants to merge 4 commits into from

Conversation

fremff
Copy link

@fremff fremff commented Jan 14, 2019

开发者你好,这是我的首个拉请求,本脚本的修改完全处于个人兴趣及需要,希望能对本项目有些许帮助。

原提交信息:

  1. 变更版本号比较方法,使用“-gt”而非“!=”;
  2. 完善脚本帮助信息,调整部分信息内容用词;
  3. 未定义选项错误提示;
  4. 缩进统一以四个空格为单位,清理拖尾空白。

一些附加说明:

  1. 用词的改变是在编辑其它内容时顺便完成的,如果有问题我可以恢复这部分内容到原状态。
  2. 已做过一定程度的测试,包括手动检查更新、将脚本加入 Crond 每日计划实现的自动更新,及直接执行脚本,在这些测试中均未发现问题,脚本可以正常工作。

变更版本号比较方法,使用“-gt”而非“!=”;

完善脚本帮助信息,调整部分信息内容用词;

未定义选项错误提示;

缩进统一以四个空格为单位,清理拖尾空白。
colorEcho ${RED} "Failed to fetch release information. Please check your network or try again."
return 3
elif [[ $RETVAL -ne 0 ]];then
return 2
elif [[ `echo $NEW_VER | cut -d. -f-2` != `echo $CUR_VER | cut -d. -f-2` ]];then
return 1
elif [[ $NEW_VER_N -gt $CUR_VER_N ]];then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一段比较是把版本号除去"."之后进行比较?这样的话 4.10 会小于 4.2 的。

Copy link
Author

@fremff fremff Jan 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一段比较是把版本号除去"."之后进行比较?这样的话 4.10 会小于 4.2 的。

是的,因为诸如-gt这样的运算符仅支持整数参数,不支持字串及带小数值,所以必须去掉小数点。而4.10与4.2这两个版本间的比较会返回为“真”的,请看:

➜  A=4.10&&B=4.2&&AA=`echo $A|sed "s/\.//"`&&BB=`echo $B|sed "s/\.//"`&&echo $AA $BB
410 42

~if [[ $AA -gt $BB ]]; thenecho "y"elseecho "n"fi
y

在最新的提交中我更新了比较方法,现在应可以做到对版本的更好比对了,避免诸如3.11大于4.2的问题--Improve logic of versions comparing

@kslr kslr closed this Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants