Quick Recap – exerpt from manpages of dos2unix & unix2dos
* In DOS/Windows text files a line break, also known as newline, is a combination of two characters: a Carriage Return (CR) followed by a Line Feed (LF).
* In Unix text files a line break is a single character: the Line Feed (LF).
* In Mac text files, prior to Mac OS X, a line break was single Carriage Return (CR) character. Nowadays Mac OS uses Unix style (LF) line breaks.
What you will need?
Notepad++
What is all this about?
When making scripts in Cygwin that you want to start from Windows, or even just when your making scripts for Cygiwn you need to be consious and aware of the line endings.
Cygwin needs to have line endings for its script that are Linux Lineendings meaning they end in LF (not the letter but thats an actual special character).
Windows scripts all end in CR+LF (Also not the letters and plus sign, but they are special characters, first the CR and then the LF character)
Here is more good info: http://en.wikipedia.org/wiki/Newline
For example:
cygwin-script.sh – Make sure this has line endings in LF
windows-batch-script.bat – Make sure this has line endings in CR+LF
Why?
Without this the script interpreters will fail on the new lines, and you will have errors that are hard to figure out whats wrong because the scripts actually seem to be written right.
How to? Line endings can be converted to the right format with Notepad++ just go Edit->EOL Conversion->Unix for LF and for CR+LF click on Dos or Windows), to see if you have the right line endings go to the View menu->Show Symbol->Show all Characters
NEVER USE WINDOWS DEFAULT NOTEPAD FOR CYGWIN SCRIPTS AS IT ALWAYS SAVES WITH CR+LF. ONLY USE SOMETHING THAT HAS NEWLINE AWARENESS LIKE NOTEPAD++