Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Make opendiff wait for FileMerge to finish UNIX
opendiff is a command line app for merging text files. It is installed when you install the Xcode Developer Tools on Mac OS X, and calls FileMerge.app. By default, opendiff does not wait for FileMerge.app to finish before exiting. This makes it hard to integrate opendiff with other Unix tools. After some searching, I found a solution.

In particular, opendiff will wait if the output is piped somewhere. I handle this by making a new shell script I call opendiff-w with the following code in it:
#! /bin/zsh
`/usr/bin/opendiff $@`
Then you can use opendiff-w just as you would opendiff, but it will wait until you quit FileMerge.app before continuing. It would be better still if FileMerge had a way to know when the diff was done without having to actually quit the app. Any suggestions?
    •    
  • Currently 2.25 / 5
  You rated: 1 / 5 (4 votes cast)
 
[11,500 views]  

Make opendiff wait for FileMerge to finish | 5 comments | Create New Account
Click here to return to the 'Make opendiff wait for FileMerge to finish' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
fmdiff
Authored by: vocaro on Feb 23, '07 10:36:51AM
You should also be aware of Bruno De Fraine's wrapper scripts for FileMerge. These allow FileMerge to be used with Subversion and other tools that require a GNU diff compatible command. (The opendiff command is not a drop-in replacement for GNU diff.) I believe as a side-effect these scripts also wait for FileMerge to exit before exiting themselves.

[ Reply to This | # ]
Make opendiff wait for FileMerge to finish
Authored by: GodFarmer on Feb 23, '07 11:13:26AM

This is Bruno De Fraine. It is often a solution to run FileMerge directly, without the opendiff wrapper.
Try /Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge

It accepts the options -left, -right, -ancestor, -merge. It will block until you close FileMerge. I'm not aware of another solution to know when the diff is done.



[ Reply to This | # ]
Try TextWrangler
Authored by: davester on Feb 23, '07 12:41:16PM

It's free, and the command line twdiff tool has a wait option that should behave like BBEdit's, which is smart enough to wait until you close the 'diff' window, so you don't have to quit the application for the script to continue.



[ Reply to This | # ]
Make opendiff wait for FileMerge to finish
Authored by: efge on Feb 23, '07 03:51:20PM
Using backquotes is pretty dangerous, it means "execute the result of the command inside the backquotes". If for some reason opendiff outputs text that can be interpreted as a dangerous command, you're screwed.

You can simply use:


/usr/bin/opendiff $@ | cat
Also you should always use $@ inside quotes (man sh explains why in the Special Parameters section). So:

/usr/bin/opendiff "$@" | cat


[ Reply to This | # ]
Make opendiff wait for FileMerge to finish
Authored by: dwave on Feb 24, '07 07:22:19AM

you could also use:

tmp=`/usr/bin/opendiff "$@"`

which wouldn't execute the output of opendiff, but take the output of opendiff and place it in the variable $tmp.



[ Reply to This | # ]