Hacking · Things I've Learned

Bourne Shell Introspection

So I was thinking about how to refactor our custom Linux and Solaris init scripts at work. The way FreeBSD does it is to have the scripts in /etc/rc.d define variables with the commands to execute, e.g., start_cmd=’/usr/sbin/foobard’ stop_cmd=’kill `cat /var/run/foobar.pid`’ run_rc_command “$1″ where $1 is “start”, “stop”, or whatever, and run_rc_command is a function… Continue reading Bourne Shell Introspection

Hacking · Perl

Evil Hack of the Day

MacOS plist XML files are evil; even more so than regular XML. For instance, my iTunes library file consists mostly of entries like: <key>5436</key> <dict> <key>Track ID</key><integer>5436</integer> <key>Name</key><string>Getting Better</string> <key>Artist</key><string>The Beatles</string> <key>Composer</key><string>Paul McCartney/John Lennon</string> <key>Album</key><string>Sgt. Pepper’s Lonely Hearts Club Band</string> … </dict> You’ll notice that there’s no connection between a key and its value, other… Continue reading Evil Hack of the Day

Hacking

Another Reason Not to Write csh Scripts

In case you haven’t read Tom Christiansen’s Csh Programming Considered Harmful, here’s another reason not to write csh/tcsh scripts if you can avoid it. Unlike the Bourne Shell, the C shell exits with “Undefined variable” if you reference an undefined variable, instead of expanding that variable to the empty string, the way the Bourne shell… Continue reading Another Reason Not to Write csh Scripts