Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Background: the Mac OS X plist format is binary by default, which is not very good for things like tracking with git. There is a command plutil -convert which can convert back and forth from binary to XML, but it doesn't seem to be possible to force a given plist file to stay as XML.

My idea is use the launchd WatchPaths functionality to set up two scripts, one that changes the binary file in ~/Library/Preferences to an XML file in my git repo, and another that back converts the binary file if the XML version changes (I need this second direction because I intend to use this to sync the two between two computers).

The only problem is, if I just set this up naively, it will run endlessly, because as soon as the binary file changes, it will update the XML file, but then this will be a change to the XML file, which will result in it updating the binary file, and so on.

Is there a clever way I can avoid this cycle. I guess what I want to do is to check in the script that converts from binary to XML if the thing that wrote the file last was the program that the preference file is for, or the script itself, and if it's the latter, to not run. Is there some sort of attribute I can put on the file that will tell it this, that will be cleared when the normal program writes the file?

share|improve this question

Apparently, at least for the one program I've been testing, if you use xattr -w to put an attribute on a file, when the preferences are changed, that attribute is removed, assumedly because it writes out a whole new file.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .