I installed CygWin on Windows 7. Using Notepad, I edited my ~/.bash_profile file to add on to the PATH variable …

PATH="${PATH}:/cygdrive/c/apache-ant-1.8.2/bin"

Now, when I SSH in to my Windows machine, I get this error …

-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: /home/dev/.bash_profile: line 39: syntax error: unexpected end of file

and my PATH is not set. Anyone know how I can correct this?

link|improve this question
1  
Egads, don't ever use notepad to edit a unix file. It adds the \r character at line endings, and as bash reported, it isn't tolerated very well. Run d2u .bash_profile to fix it. Also, you should ask questions like this on superuser not stackoverflow. – Amardeep Sep 1 '11 at 13:40
feedback

migrated from stackoverflow.com Sep 1 '11 at 14:26

This question came from our site for professional and enthusiast programmers.

2 Answers

As mentioned already, Windows uses \n\r as line separator. Now that you've got the \rs in your .bash_profile, however, you can use the utility dos2unix to remove them.

link|improve this answer
3  
Windows uses \r\n, not \n\r. – Keith Thompson Sep 1 '11 at 14:41
feedback

Probably notepad has added some $'\r', i. e. CR characters - as it is usual under Windows to have CRLF as line terminator.

The solution would be to use another editor which is capable to keep the line endings as they are, e. g. vim for Windows, or Notepad2.

link|improve this answer
This is not an answer. This is a comment. – musiKk Sep 1 '11 at 13:54
1  
I'm usually bothered by answers that should be comments, but this does imply that the OP should just stop using Notepad, and as such I think it qualifies as an answer (if not a very good one). – Lord Torgamus Sep 1 '11 at 20:04
Extended the answer in order to qualify as one. Are there any alternatives to changing the editor? – glglgl Sep 2 '11 at 7:46
feedback

Your Answer

 
or
required, but never shown