[英]Latest version of Git in Bash?
Trying to the pull the latest version of Git from http://git-scm.com but the script below doesn't seem to be printing out anything...试图从http://git-scm.com拉取最新版本的 Git,但下面的脚本似乎没有打印出任何东西......
What am I missing here?我在这里缺少什么?
if [ -z "$CURRENT_GIT_VERSION" ]; then
if [ "`uname`" == "Darwin" ]; then
sed_regexp="-E";
else
sed_regexp="-r";
fi
CURRENT_GIT_VERSION=$(curl http://git-scm.com/ 2>&1 | grep '<span class="version">' -A 1 | tail -n 1 | sed $sed_regexp 's/ *//')
fi
echo "$CURRENT_GIT_VERSION"
Not working:不工作:
CURRENT_GIT_VERSION=$(curl -silent http://git-scm.com/ | sed -n '/id="ver"/ s/.*v\([0-9].*\)<.*/\1/p')
echo "$CURRENT_GIT_VERSION"
Also not working:也不起作用:
CURRENT_GIT_VERSION=$(echo $(curl -s http://git-scm.com/ | grep 'class="version"' -A 2) | perl -pe 's/.*?([0-9\.]+).*/$1/')
echo "$CURRENT_GIT_VERSION"
The problem is that http://git-scm.com/
is redirecting to https://git-scm.com/
, and curl
doesn't follow redirects by default.问题是
http://git-scm.com/
正在重定向到https://git-scm.com/
,默认情况下curl
不遵循重定向。
Try fetching from https://git-scm.com/
directly.尝试直接从
https://git-scm.com/
获取。
Alternatively, add a -L
option to the curl
command to get it to follow redirects.或者,向
curl
命令添加-L
选项以使其跟随重定向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.