Line Endings

Originally posted by ridefree
How does OSX deal with the difference in line endings between Mac text files and Unix text files?

Wow! That was a good question!

For years I've been a Mac guy doing Web stuff for Unix servers. That means I've always had to be carful to save my files with Unix line breaks.

So I conducted a few little tests:

1) I opened some files burried within /System and /Library. To my surprise these files all had Mac line breaks.

2) Next I created a file with pico (sorry to admit my vi skills are poor). Then I opened this file with BBedit to see what had happened. To my surprose this new text file also had Mac line breaks.

3) So I saved this file with Unix line breaks and opened it up again in pico. pico opened it without complaint, but again saved it with Mac line breaks.

So to my surprise Mac line breaks are still Mac line breaks. I was really hoping that we'd now be using Unix line breaks now.

So I guess I still have to carefully convert these when publishing cgi's and such to our Solaris boxes. Grrr....
Well vi doesn't like mac line breaks.

Also a couple of things I downloaded to compile wouldn't compile because of mac line breaks. It turned out that when stuffit unpacked a .tgz file it converted the line breaks to mac format. I've had to disable stuffit for tgz, tar, and tar.gz files to prevent that and now just unpack from the command line.

When I get to work on Monday, I'll pull out my vi reference mug and try this out.

I think I misread the original post when I responded. However I know it is possible to make a perl script to convert Mac line breaks to Unix and vice versa.

Maybe that would be a good command line way to deal with it if you don't want to use something like BBEdit.

BTW, my pico on Solaris does not like Mac line breaks, so it seems they tweaked the OS X one so that it would be okay with them. I wonder why they would have tweaked pico and not vi. Has anyone tried emacs yet?