意外标记 `$'in\r'' 附近存在语法错误

发布于 2024-11-17 05:35:15 字数 574 浏览 4 评论 0原文

我正在尝试编译 NIST 生物识别图像软件,但一整天都遇到了麻烦。我终于正确检查了源代码,并且安装了 cygwin 没有任何问题(我过去使用过它),但是当我去编译时,我收到此错误:

 $  sh setup.sh </cygdrive/c/NBIS> [--without-X11]
 setup.sh: line 94: syntax error near unexpected token `$'in\r''
 'etup.sh: line 94: `    case $1 in

现在我确信任何高级编码器都会前往setup.sh 并查找问题,但我并不是一个真正的编码员(我只是编译这个,因为没有预编译的包)所以我不知道该怎么做。我没有使用 cygwin 安装任何库,我只是将所有内容保留为默认值。我正在尝试遵循 NBIS 手册,但我不太理解它,所以我很挣扎。也许看一下它,您可能会注意到我错过了一些东西:http://www.nist.gov/customcf /get_pdf.cfm?pub_id=51097

I'm trying to compile the NIST Biometric Image Software, and I have been having trouble all day. I finally got the source checked out right, and I installed cygwin with no problems (I have used it in the past), but when I went to compile, I get this error:

 $  sh setup.sh </cygdrive/c/NBIS> [--without-X11]
 setup.sh: line 94: syntax error near unexpected token `

Now I'm sure any advanced coder would head to the setup.sh and look for problems, but I'm not really much of a coder (I'm only compiling this because there are no pre-compiled packages) so I don't know what to do. I didn't install any libraries with cygwin, I just left everything default. I'm trying to follow the NBIS manual, but I don't really understand it that well and so I'm struggling badly. Maybye taking a look at it you may notice something I missed: http://www.nist.gov/customcf/get_pdf.cfm?pub_id=51097

in\r'' 'etup.sh: line 94: ` case $1 in

Now I'm sure any advanced coder would head to the setup.sh and look for problems, but I'm not really much of a coder (I'm only compiling this because there are no pre-compiled packages) so I don't know what to do. I didn't install any libraries with cygwin, I just left everything default. I'm trying to follow the NBIS manual, but I don't really understand it that well and so I'm struggling badly. Maybye taking a look at it you may notice something I missed: http://www.nist.gov/customcf/get_pdf.cfm?pub_id=51097

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

寄人书 2024-11-24 05:35:15

运行

sed -i 's/\r//' setup.sh

来修复你的行结尾

run

sed -i 's/\r//' setup.sh

to fix your line endings

能怎样 2024-11-24 05:35:15

这是行结束不匹配的症状。

要将 setup.sh 转换为 Cygwin 上的 Unix 行结尾,请使用

dos2unix setup.sh

That's a symptom of line-ending mismatch.

To convert setup.sh to Unix line endings on Cygwin, use

dos2unix setup.sh
十秒萌定你 2024-11-24 05:35:15

将 example.sh 文件转换为 unix 的简单方法是使用 NotePad++(编辑>EOL 转换>UNIX/OSX 格式)。

您还可以在 notepad++ 中设置默认 EOL(设置>首选项>新文档/默认目录>选择 Unix/OSX 下的格式框)

Easy way to convert example.sh file to unix is use NotePad++ (Edit>EOL Conversion>UNIX/OSX Format)

You can also set the default EOL in notepad++ (Settings>Preferences>New Document/Default Directory>select Unix/OSX under the Format box)

凌乱心跳 2024-11-24 05:35:15

在 pycharm 中,您可以通过单击屏幕右下角的字母 CRLF 并选择 LF 来快速更改行结尾。

pycharm 行结尾位置

In pycharm you can quickly change the line endings by clicking on the letters CRLF at the bottom right of the screen and selecting LF.

pycharm line endings location

£冰雨忧蓝° 2024-11-24 05:35:15

Windows 使用两个字符(CR 和 LF,或 \r\n)来标记文本文件中的行结束。 Unix、Linux 和(默认情况下)Cygwin 使用单个 LF 或“\n”字符。一些 Cygwin 工具能够处理这两种格式,但 sh 通常不能。

看起来 setup.sh 使用了 Windows 风格的行结尾——或者至少第 94 行是这样。

我没有找到源文件的下载,但如果它们作为 zip 文件分发,您可能需要使用 Cygwin unzip 命令和 -a 选项,因此任何行结尾都会自动转换。

但我怀疑事情远不止于此。分布式 setup.sh 文件一开始就不应该有任何 Windows 风格的行结尾,如果有的话,我不知道为什么问题直到第 94 行才出现如果

您可以发布源下载的 URL,我会看一下 setup.exe

Windows uses two characters (CR and LF, or \r\n) to mark the end of a line in a text file. Unix, Linux, and (by default) Cygwin use a single LF or '\n' character. Some Cygwin tools are able to deal with either format, but sh typically can't.

It looks like setup.sh uses Windows-style line endings -- or at least line 94 does.

I didn't find the download for the sources, but if they're distributed as a zip file, you might need to extract them using the Cygwin unzip command with the -a option, so any line endings are automatically converted.

But I suspect there's more to it than that. The distributed setup.sh file shouldn't have had any Windows-style line endings in the first place, and if it did, I don't know why the problem wouldn't show up until line 94.

If you can post the URL for the source download, I'll take a look at setup.exe.

用心笑 2024-11-24 05:35:15

我曾经遇到过同样的问题,但我使用记事本++解决了它

安装记事本++,使用记事本++打开你的shell代码,转到“编辑”菜单,选择“EOL转换,选择“Unix(LF)”选项,它应该被修复

或者,如果您使用 Visual Studio Code,则可以将 CRLF 更改为 LF

视觉Studio代码

Notepad++

I used to have the same issue but I solved it using notepad++

Install Notepad++, Open your shell code using Notepad++, Go to the "Edit" menu, Select "EOL Conversion, Choose the "Unix (LF)" option and it should be fixed

or if you use Visual Studio Code you can change CRLF to LF

Visual Studio Code

Notepad++

ヅ她的身影、若隐若现 2024-11-24 05:35:15

我遇到了同样的问题。我使用的是 Windows 11、WSL 和 Ubuntu 发行版。

这个错误是由于脚本是在Windows机器上编辑的,它使用回车符(\r)和换行符(\n)作为行结尾,而基于Unix的系统(如Linux)仅使用换行符( \n)。

我通过使用 dos2unix 命令解决了这个问题。

以下是具体操作方法。

只要跑:

dos2unix setup.sh

就你的情况而言。

注意:您可能需要通过运行 sudo apt install dos2unix 来安装 dos2unix

I came across the same issue. I am using Windows 11, with WSL and Ubuntu distro.

This error is due to the fact that the script was edited on a Windows machine, which uses carriage return (\r) and line feed (\n) as line endings, while Unix-based systems (like Linux) only use line feed (\n).

I fixed this problem by using the dos2unix command.

Here is how to do it.

Just run:

dos2unix setup.sh

In your case.

NB: You may need to install dos2unix by running sudo apt install dos2unix

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文