<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Wrapping &#8216;defaults&#8217; to be more flexible&#8230;</title>
	<atom:link href="http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/feed/" rel="self" type="application/rss+xml" />
	<link>http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/</link>
	<description>many a slip 'twixt mind and lip...</description>
	<lastBuildDate>Thu, 10 Dec 2009 20:56:50 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: nigel kersten</title>
		<link>http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/comment-page-1/#comment-1528</link>
		<dc:creator>nigel kersten</dc:creator>
		<pubDate>Tue, 22 Apr 2008 13:07:25 +0000</pubDate>
		<guid isPermaLink="false">http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/#comment-1528</guid>
		<description>heh.

So I&#039;ve been writing heaps of Python since moving to Google, (well we did hire Guido, what do you expect? :) ) and have been doing a lot of plistlib work, as well as dealing with the Ruby plist stuff.

Why has no-one reverse engineered the binary format yet?

Is it just that it&#039;s really easy to coerce an XML parser into parsing the xml1 format and no-one could be bothered doing the work?

Is it that Apple themselves don&#039;t seem to have documented it?

I&#039;m sick of wrapping plutil -convert commands in try: except: or begin rescue blocks and it&#039;s not always appropriate. Sometimes you want to read the plist before requesting elevated privileges to make changes to it.

Now I think about it, I&#039;ve actually started writing a whole bunch of Ruby wrappers that use PlistBuddy instead, now that it&#039;s at /usr/libexec/ in Leopard. It really annoys me how &#039;defaults&#039; logs to syslog every time you query for a non-existent key, no matter where you redirect stdout/stderr.</description>
		<content:encoded><![CDATA[<p>heh.</p>
<p>So I&#8217;ve been writing heaps of Python since moving to Google, (well we did hire Guido, what do you expect? :) ) and have been doing a lot of plistlib work, as well as dealing with the Ruby plist stuff.</p>
<p>Why has no-one reverse engineered the binary format yet?</p>
<p>Is it just that it&#8217;s really easy to coerce an XML parser into parsing the xml1 format and no-one could be bothered doing the work?</p>
<p>Is it that Apple themselves don&#8217;t seem to have documented it?</p>
<p>I&#8217;m sick of wrapping plutil -convert commands in try: except: or begin rescue blocks and it&#8217;s not always appropriate. Sometimes you want to read the plist before requesting elevated privileges to make changes to it.</p>
<p>Now I think about it, I&#8217;ve actually started writing a whole bunch of Ruby wrappers that use PlistBuddy instead, now that it&#8217;s at /usr/libexec/ in Leopard. It really annoys me how &#8216;defaults&#8217; logs to syslog every time you query for a non-existent key, no matter where you redirect stdout/stderr.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Heath Raftery</title>
		<link>http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/comment-page-1/#comment-1526</link>
		<dc:creator>Heath Raftery</dc:creator>
		<pubDate>Tue, 22 Apr 2008 08:15:30 +0000</pubDate>
		<guid isPermaLink="false">http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/#comment-1526</guid>
		<description>Whoops, major html tag gobbling. I&#039;ll try the code again:

&lt;code&gt;
#!/bin/bash

# plcat, cat binary plists as XML.
# By Tom Harrington, June 2005.  .

# Usage:
# plcat 
# or:
# plcat  $tempfile
        # convert temp file in place
        /usr/bin/plutil -convert xml1 $tempfile
else
        # plutil doesn&#039;t write to stdout, so the result gets saved and then accessed.
        /usr/bin/plutil -convert xml1 -o $tempfile $1;
fi
if [ -e $tempfile ]; then
        /bin/cat $tempfile;
        /bin/rm -i -f $tempfile;
fi
&lt;/code&gt;

By the way, despite the usage comment, the regular old &quot;plcat file&quot; syntax also works.</description>
		<content:encoded><![CDATA[<p>Whoops, major html tag gobbling. I&#8217;ll try the code again:</p>
<p><code><br />
#!/bin/bash</p>
<p># plcat, cat binary plists as XML.<br />
# By Tom Harrington, June 2005.  .</p>
<p># Usage:<br />
# plcat<br />
# or:<br />
# plcat  $tempfile<br />
        # convert temp file in place<br />
        /usr/bin/plutil -convert xml1 $tempfile<br />
else<br />
        # plutil doesn't write to stdout, so the result gets saved and then accessed.<br />
        /usr/bin/plutil -convert xml1 -o $tempfile $1;<br />
fi<br />
if [ -e $tempfile ]; then<br />
        /bin/cat $tempfile;<br />
        /bin/rm -i -f $tempfile;<br />
fi<br />
</code></p>
<p>By the way, despite the usage comment, the regular old &#8220;plcat file&#8221; syntax also works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Heath Raftery</title>
		<link>http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/comment-page-1/#comment-1525</link>
		<dc:creator>Heath Raftery</dc:creator>
		<pubDate>Tue, 22 Apr 2008 08:11:07 +0000</pubDate>
		<guid isPermaLink="false">http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/#comment-1525</guid>
		<description>I also tend to use defaults using only the domain syntax:

% defaults read com.apple.loginwindow

And plutil for plist file manipulation. Naturally, it needs a wrapper too! Here&#039;s the one I use:

&lt;code&gt;
#!/bin/bash

# plcat, cat binary plists as XML.
# By Tom Harrington, June 2005.  .

# Usage:
# plcat 
# or:
# plcat  $tempfile
        # convert temp file in place
        /usr/bin/plutil -convert xml1 $tempfile
else
        # plutil doesn&#039;t write to stdout, so the result gets saved and then accessed.
        /usr/bin/plutil -convert xml1 -o $tempfile $1;
fi
if [ -e $tempfile ]; then
        /bin/cat $tempfile;
        /bin/rm -i -f $tempfile;
fi
&lt;/code&gt;

Nicholas&#039; function looks neater, but isn&#039;t pl deprecated? As you can see from the date, Tom wrote the above script for a not-so-current version of OS X.</description>
		<content:encoded><![CDATA[<p>I also tend to use defaults using only the domain syntax:</p>
<p>% defaults read com.apple.loginwindow</p>
<p>And plutil for plist file manipulation. Naturally, it needs a wrapper too! Here&#8217;s the one I use:</p>
<p><code><br />
#!/bin/bash</p>
<p># plcat, cat binary plists as XML.<br />
# By Tom Harrington, June 2005.  .</p>
<p># Usage:<br />
# plcat<br />
# or:<br />
# plcat  $tempfile<br />
        # convert temp file in place<br />
        /usr/bin/plutil -convert xml1 $tempfile<br />
else<br />
        # plutil doesn't write to stdout, so the result gets saved and then accessed.<br />
        /usr/bin/plutil -convert xml1 -o $tempfile $1;<br />
fi<br />
if [ -e $tempfile ]; then<br />
        /bin/cat $tempfile;<br />
        /bin/rm -i -f $tempfile;<br />
fi<br />
</code></p>
<p>Nicholas&#8217; function looks neater, but isn&#8217;t pl deprecated? As you can see from the date, Tom wrote the above script for a not-so-current version of OS X.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jaharmi</title>
		<link>http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/comment-page-1/#comment-1456</link>
		<dc:creator>Jaharmi</dc:creator>
		<pubDate>Tue, 04 Dec 2007 05:46:42 +0000</pubDate>
		<guid isPermaLink="false">http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/#comment-1456</guid>
		<description>I’m just as happy using the plistlib from Python, myself, compared to what you get from `defaults`. I haven’t tried the latest version that ships with Python 2.5.1, but if it has developed support for binary plists, that’d make it even better.

But, yes, `defaults` even with its warts, still has an edge at the command line so your function is a good idea.</description>
		<content:encoded><![CDATA[<p>I’m just as happy using the plistlib from Python, myself, compared to what you get from `defaults`. I haven’t tried the latest version that ships with Python 2.5.1, but if it has developed support for binary plists, that’d make it even better.</p>
<p>But, yes, `defaults` even with its warts, still has an edge at the command line so your function is a good idea.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Riley</title>
		<link>http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/comment-page-1/#comment-1446</link>
		<dc:creator>Nicholas Riley</dc:creator>
		<pubDate>Thu, 22 Nov 2007 02:21:46 +0000</pubDate>
		<guid isPermaLink="false">http://explanatorygap.net/2007/11/22/wrapping-defaults-to-be-more-flexible/#comment-1446</guid>
		<description>Cool, yeah, I&#039;ve had the same problem.

Another plist-type function I wrote:

plv () {
        plutil -convert xml1 -o /dev/fd/1 $1 &#124; /usr/bin/pl
}

useful to view a property list since /usr/bin/pl (even in Leopard) still doesn&#039;t support binary property lists.</description>
		<content:encoded><![CDATA[<p>Cool, yeah, I&#8217;ve had the same problem.</p>
<p>Another plist-type function I wrote:</p>
<p>plv () {<br />
        plutil -convert xml1 -o /dev/fd/1 $1 | /usr/bin/pl<br />
}</p>
<p>useful to view a property list since /usr/bin/pl (even in Leopard) still doesn&#8217;t support binary property lists.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
