Line endings, scripts, and jEdit

1 reply [Last post]
User offline. Last seen 2 days 18 hours ago. Offline
Joined: 08/04/2010

When working through your first script in Chapter 6, you may get some strange errors and feedback:

ls: unknown option --
Try 'ls --help' for more information.
Above are the directory listings for this folder:
/home/lucy/scripts/ line 4: $'pwd\r': command not found
Right, now it is:
/home/lucy/scripts/ line 6: $'date\r': command not found

These are caused by incorrect Windows line endings being applied by jEdit. As explained in Chapter 1, Windows systems use two characters (\r\n) to mark the end of a line, whereas the Unix shell expects just \n. When your script contains \r, it gets interpreted as a character by the shell and causes various errors.

To fix it, you can reset the line separator character in jEdit using these jEdit instructions.

Thanks to André L. for bringing this problem to our attention.