Carriage return causes error in bash in Cygwin

Problem:

When trying to run a bash script in Cygwin you may experience mysterious errors, like

  • ‘\r’ : command not found

or

  • “No such file or directory” with \#015 here and there in the file paths.

Reason:

Did you use Windows software to edit the shell script file?

If so, the problem is extra carriage return symbol (cr aka \#015) added by Windows at the end of the strings.

Solution:

Clean your shell file by running it through dos2unix utility before execution.

Rename the script file, say script.sh to something like script.dos, then run

  • dos2unix script.dos script.sh

 

 

 

Advertisements

One Comment on “Carriage return causes error in bash in Cygwin”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s