【发布时间】:2011-02-25 19:31:49
【问题描述】:
我正在编写一个 git-install.sh 脚本: http://gist.github.com/419201
要获取 Git 最新的稳定版本号,我这样做:
LSR_NUM=$(curl -silent http://git-scm.com/ | sed -n '/id="ver"/ s/.*v\([0-9].*\)<.*/\1/p')
2 个问题:
重构我的代码:有没有更好的编程方式来做到这一点?
-
现在可以了,但它很脆弱:如果 网页http://git-scm.com/ 变化,上面的行可能会停止 工作。
PHP 有一个可靠的 URL 用于获取 最新发布版本: Is there a site which simply outputs the latest stable version numbers of php and mysql?
有没有这样的 吉特?这很接近:http://www.kernel.org/pub/software/scm/git/
【问题讨论】:
-
您可以继续您当前的策略,但也可以通过解析
http://www.kernel.org/pub/software/scm/git/和/或http://git.kernel.org/?p=git/git.git;a=summary那里的最高数字并检查是否匹配来进行理智检查。