2012年10月31日 星期三

[bash] $'\r': command not found


Error:
I got message below when I execute a bash script.
D:/asmbin/gnuasm: line 2: $'\r': command not found
D:/asmbin/gnuasm: line 4: $'\r': command not found

Solution:
It is caused by end of line is Windows style '\n\r'
Unix think the eol should be '\n'
Mac think the eol should be '\r'

The bash is unix environment, so we have to change '\n\r' to 'n'.
I use notepad++ as editor to fix the script.

Reference:
http://stackoverflow.com/questions/11616835/cgywin-r-command-not-found-bashrc-bash-profile
http://chunshucaca.blog.163.com/blog/static/6045100020082317363713/

沒有留言:

張貼留言