User login

Wasted a lot of time with Filemerge insisting huge paste was one line

Wasted a lot of time trying to compare the results of two drupal_set_message print array wrapped in pre tags, copied out of the browser.

Various text editors treated it as having multiple lines (around 3,000 lines, in fact) but FileMerge insisted that it was one giant line. I tried saving, again with multiple editors, to Unix line ending type. I do use Unix-style line breaks by default ("LF") but this had no effect.

Anyone have any experience/advice on this?

FileMerge uses diff, and it doesn't work in diff either.

If I look at it in vi I see ^M^M and ^M instead of line breaks.

Resolution

Ahh: http://www.macosxhints.com/article.php?story=20001206164827794

If you see a bunch of ^M's in the file, you have Mac line breaks. There are some shell commands [editor's note - see the comments for a one-line perl command to fix your files!] that can auto-replace them, but I just used a Mac text editor (either jedit, BBedit, or Alpha) and re-saved the file, making sure to specify UNIX as the file type.

perl -pi -e 's/\r/\n/g' [filename]

That did it!

Searched words: 
diff Mac OS X Macintosh merge files line endings

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.