syntax error near unexpected token `$'in\r''

前端 未结 5 2036
南旧
南旧 2020-12-04 16:27

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

相关标签:
5条回答
  • 2020-12-04 17:00

    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.

    0 讨论(0)
  • 2020-12-04 17:12

    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.

    0 讨论(0)
  • 2020-12-04 17:17

    run

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

    to fix your line endings

    0 讨论(0)
  • 2020-12-04 17:19

    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)

    0 讨论(0)
  • 2020-12-04 17:20

    That's a symptom of line-ending mismatch.

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

    dos2unix setup.sh
    
    0 讨论(0)
提交回复
热议问题