在正则表达式中更改libssh2和libssl2的版本?
我正在尝试拥有自己的bash脚本frugghi issh脚本来为苹果平台生成libssl和libssh库。我想尝试自己的bash脚本的原因是获取最近的libs并继续更新。
我有两个bash脚本来检测openssl和libssh2 libs的最新版本:
getLibssh2Version () {
if type git >/dev/null 2>&1; then
LIBSSH_VERSION=`git ls-remote --tags https://github.com/libssh2/libssh2.git | egrep "libssh2-[0-9]+(\.[0-9])*[a-zA-Z]?$" | cut -f 2 -d - | sort -t . -r | head -n 1`
LIBSSH_AUTO=true
}
但是,
getOpensslVersion () {
if type git >/dev/null 2>&1; then
LIBSSL_VERSION=`git ls-remote --tags git://git.openssl.org/openssl.git | egrep "OpenSSL(_[0-9])+[a-zA-Z]?$" | cut -f 2,3,4 -d _ | sort -t _ -r | head -n 1 | tr _ .`
LIBSSL_AUTO=true
}
第一个脚本获取了1.9.0版本的libssh2,而不是1.10.0,而第二个脚本fetches openssl openssl openssl openssl则为1.1.1n系列而不是3.0.2.2 (尽管两者都是一样的)。我想这与定义的正则表达式有关。有人可以整理此脚本错误吗?
I am trying to have my own bash script Frugghi issh script to generate libssl and libssh libraries for apple platforms. Reason why i want to try my own bash script is to fetch the recent libs and keep updated.
I have two bash scripts to detect the recent version of openssl and libssh2 libs:
getLibssh2Version () {
if type git >/dev/null 2>&1; then
LIBSSH_VERSION=`git ls-remote --tags https://github.com/libssh2/libssh2.git | egrep "libssh2-[0-9]+(\.[0-9])*[a-zA-Z]?quot; | cut -f 2 -d - | sort -t . -r | head -n 1`
LIBSSH_AUTO=true
}
and
getOpensslVersion () {
if type git >/dev/null 2>&1; then
LIBSSL_VERSION=`git ls-remote --tags git://git.openssl.org/openssl.git | egrep "OpenSSL(_[0-9])+[a-zA-Z]?quot; | cut -f 2,3,4 -d _ | sort -t _ -r | head -n 1 | tr _ .`
LIBSSL_AUTO=true
}
But the first script fetches the Libssh2 of 1.9.0 version instead of 1.10.0 and the second script fetches OpenSSL of 1.1.1n series instead of 3.0.2 (though both are same). I guess it is something related to the regular expression defined . Can someone sort out this script error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的第一个片段中:
1.10.0
版本中的egrep
带有(\。[0-9])*
wher应该是(\。[0-9]+)*
。sort
需要更多选项:-t。 -K 1,1N -K 2,2N
tail
而不是head
,因为反向排序不以某种方式使用其他选项(至少在我的机器上)。解决方案:
输出:
在第二个片段中:
egrep
滤除。而不是egrep“ openssl(_ [0-9])+[a-za-z]?$“
,我都会天真地使用egrep -i” openssl([_.--- ] [0-9])+[a-za-z]?$“
。剪切
的“提取”版本对于新版本失败。自发地,我选择使用sed's /.* openssl .// i'
做同样的事情。head
转换为tail
。sort
遇到与第一个摘要相同的问题,即当这些子修复开始滚动时,例如3.9 ...
3.10 ...
,您需要添加与上面的相同选项。解决方案:
输出:
In your first snippet:
1.10.0
version in youregrep
with(\.[0-9])*
which should be(\.[0-9]+)*
.sort
needs more options:-t. -k 1,1n -k 2,2n
tail
instead ofhead
, as reverse sorting somehow does not work with the other options (on my machine, at least).Solution:
Output:
In the second snippet:
egrep
. Instead ofegrep "OpenSSL(_[0-9])+[a-zA-Z]?$"
, I'd naively useegrep -i "OpenSSL([_.-][0-9])+[a-zA-Z]?$"
.cut
fails for the newer versions. Spontaneously, I chose to usesed 's/.*openssl.//i'
to do the same.head
totail
.sort
ing suffers from the same problem as in the first snippet, i.e. when these subrevisions start rolling over, e.g. from3.9...
to3.10...
, you'll need to add the same options as above.Solution:
Output:
您需要perl样式的正则匹配,该匹配是
-op
grep
的选项。获取
libssh2
最新版本。获取
openssl
最新版本。You need Perl style regex matching which does the
-oP
option ofgrep
.Getting the
libssh2
latest version.Getting the
openssl
latest version.