Script Editor.app: newlines are formatted as CR rather than LF I often use the builtin Script Editor.app to write, compile, and debug AppleScripts before I copy/paste the polished code into a shell script (with #!/usr/bin/osascript). That said, one really annoying thing is that the code I copied from Script Editor always uses CR as line delimiters, rather than the Unix (including OS X) standard LF. As a result I always have to tr '\r' '\n' before pasting into scripts, or they won't work (and won't even cat nicely).


I just want to know if others can confirm this issue? (I'm running OS X 10.10.1 now with Script Editor 2.7, but IIRC the same behavior was with 10.9 and earlier.) 
Also, any guesses on why this is happening? Is it possible that Apple never rewrote the relevant code ever since classic Mac OS (that would be insane...)?
Below is a screenshot showing the raw clipboard data when copying three lines from Script Editor.app on OS X 10.10.1:



The lines in Script Editor appear as:



The outcome depends on your destination text editor when pasting. The copied lines are encoded in multiple formats on the clipboard. The destination of the paste determines which format is preferred.

For example, pasting from Script Editor to BBEdit results in LF line delimiters. However, that is the default line ending style I have set in BBEdit.