zargrep: grep files in a zip archive

How do you search for strings within a zip archive?

I’m tinkering with EPUB3 files, and I wanted to be able to find certain strings within .epub files, so I had a look around, and I immediately found zgrep and family. The trouble was that zgrep assumes a single zipped file, not an archive.

So, without further ado, I wrote the following script, which I called, naturally, zipgrep. It uses grep and unzip, which it assumes to be available on the PATH.  Not wanting to have to pick through the argument list, I decided to mark the end of arguments to grep with the traditional ‘‘, after which I could stack up as many zip file names as I liked.

Continue reading “zargrep: grep files in a zip archive”

Redefining marriage

Brendan O’Neill raises a point which I have never heard in the discussion before, but which I have always felt is critical. This unprecedented redefinition of the basic building block of human society rewrites the contract that the State entered into with every currently married person. How’s that for retrospective legislation? I will return to this point below.

Continue reading “Redefining marriage”

Setting environment variables in MacOS Big Sur

This method uses launchctl to manage environment variables for programs invoked directly from Finder.  See the launchctl man page, especially the section LEGACY SUBCOMMANDS.  It’s not entirely accurate, but that’s not unusual.  The critical subcommands are getenv, setenv, and unsetenv. The man page indicates that the export subcommand is available; it is not.

Continue reading “Setting environment variables in MacOS Big Sur”

Identity Theft

On the 10th of October, 2010, Natasha Mitchell interviewed Thomas Metzinger on the Australian Broadcasting Corporation’s Radio National network program All in the Mind. The show was titled You are not a self! Bodies, brains and the nature of consciousness. The ABC is the Government-financed public broadcaster in Australia. Radio National (RN) is an AM radio network dedicated to cultural and scientific topics that do not get much airplay on commercial radio. Metzinger was introduced on the programme like so:

Professor Metzinger is based at the Johannes-Gutenberg University in Mainz in Germany, and has long collaborated with neuroscientists and artificial intelligence researchers and others. And in his new book The Ego Tunnel: The Science of the Mind and the Myth of the Self he makes the case that there is no such thing as a self.

Continue reading “Identity Theft”

Ant: process elements in a list

I was looking for a way to process a list of items in an ant build file, similar to what you would do in Java with a construct like:

for ( Element element : elements ) {
    // do stuff with element
}

The approach of XSLT, using recursive calls with local variables, looked promising. In the ant-user mailing list, I found a posting on the topic Implementing a loop in ANT with something like what I was looking for. Ben Stringer’s example gave me the critical information—that I could make indirecly recursive calls to antcall. He also used an external file, updated with the buildnumber task, to maintain state through the recursive calls. Bingo!

Continue reading “Ant: process elements in a list”

Ant: edit property values

One of the frustrations of using ant was the difficulty of deriving one property value performing some sort of editing operation on an existing property value. The mapper task does a lot of grunt work for file names, but not for property values as such.

A common requirement is to map a Java package name to a corresponding directory structure. I have a property containing the package name, and I want to create another property with the directories. Here’s one way to do that. Continue reading “Ant: edit property values”

Using environment.plist with Mountain Lion

UPDATE
This post is now obsolete. For the preferred method in both Mountain Lion and Mavericks, see  Setting environment variables in OS X Mountain Lion and Mavericks. With Mountain Lion (OS X 10.8), the environment settings from ~/.MacOSX/environment.plist are not taken into account when the background system environment is set up by launchd, the OS X initialisation process. Consequently, if you want settings like $JAVA_HOME to be available to Java applications you start from Finder, you must find an alternative for setting them.

Continue reading “Using environment.plist with Mountain Lion”

Setting Environment Variables in OS X Lion

If you want to set environment variables in OS X in such a way as to be recognised in applications run from Finder, it is not enough to set the env var in .profile.  You must also ensure that the variables are set in the file ~/.MacOSX/environment.plist. Setting values in that file is most conveniently done using the executable PlistBuddy.

On my system, the command
$ which PlistBuddy
yields
/usr/sbin/PlistBuddy

Continue reading “Setting Environment Variables in OS X Lion”