SH-1017The script uses Windows/DOS style \r\n
line terminators instead of UNIX style \n
terminators.
The additional \r
aka ^M
aka carriage return
characters will be treated literally, and result in all sorts of strange bugs and messages.
You can verify this with cat -v yourfile
and see whether or not each line ends with a ^M
.
To delete them, open the file in your editor and save the file as "Unix", "UNIX/OSX Format", :set ff=unix
or similar if it supports it.
You can also use tr
to do it:
tr -d '\r' < badscript > goodscript
Problematic code:
$ cat -v myscript
#!/bin/sh^M
echo "Hello World"^M
Correct code:
$ cat -v myscript
#!/bin/sh
echo "Hello World"