且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Bash if 或语句,找不到命令

更新时间:2022-06-25 03:53:20

这是你的问题:

+ ' [' 17.04 == 17.04 ']'

您在最后一个 [ 之前似乎有某种时髦的空格字符.删除并重新键入它以将其转换为常规的 ascii 空间.

You appear to have some kind of funky space character before the last [. Delete and retype it to turn it into a regular ascii space.

当您在此处复制粘贴该行时,或通过非原始 github 视图查看它时,它会被转换为常规空间,因此它不会出现在您的帖子中.这也是为什么当复制粘贴到另一个文件时它工作得很好.

When you copy-pasted the line here, or when viewing it via the non-raw github view, it's being translated into a regular space, so it's not present in your post. This is also why it works just fine when copy-pasted into another file.

这是对从 github 下载(而非复制粘贴)的文件的 ShellCheck:

Here's ShellCheck on the file as downloaded (and not copy-pasted) from github:

$ shellcheck install_mongo.sh

In install_mongo.sh line 8:
    if [ "$(lsb_release -r -s)" == "16.04" ] || [ "$(lsb_release -r -s)" == "17.04" ]; then
                                               ^-- SC1018: This is a unicode non-breaking space. Delete and retype it.