« Tabclearing | Main | Some thoughts on Leopard after a couple of days »

Leopard gotcha - COMMAND_MODE="legacy"

So, I recently upgraded my MacBook to Leopard. Smooth upgrade, very few problems, and one absolutely mind-numbingly stupid "compatibility" issue that has caused me to waste an entire day, reduced to a quivering pile of helpless, angry muscle and bone, because the immediate result was that I could not compile anything at all.

I use bash as my default shell, and have since OS X Beta days, and have built out a number of libraries, customized perl, and so forth, to support my work on enemieslist. Most of these use GNU autoconf, to enable cross-platform portability and simple compilation/installation. I had done an "archive and install" upgrade, which naturally - and as expected - means I needed to install new versions of certain custom libraries, perl modules, and so forth.

Unfortunately, the upshot was that when I went to compile fresh versions for this new OS, I kept getting strange errors from GNU configure. You know, the toolset that most open source projects are written in, whose sole purpose is to work around slight (and sometimes not so slight) differences between the various *nix platforms? Yeah, well it wasn't working. At all. Just kept bailing at the stage where it tried to create libtool.

configure: creating libtool
configure: error: invalid tag name: CXX

It ostensibly seemed like a problem with libtool, or maybe sed, but it turned out to be a problem with a change in the behavior of "echo", one of those hoary old Unix programs that probably hasn't changed much at all in thirty years or more. More to the point, it's a change in order to comply with the Single Unix Specification.

It used to be that "echo -en" would suppress the addition of a newline, and enable the detection of certain special character sequences (e.g., for whitespace and other "unprintable" characters). And it's still that way in the echo built into Bash. But the echo distributed with Leopard's /bin/sh apparently just prints "-en" - breaking every piece of software that relies on GNU autoconf to compile and assumes that nobody would screw around with /bin/sh.

I found this discussion of the issue on macosxhints, and installed the bash from MacPorts, changed my shell and rebooted just to be sure; sadly, I forgot that you also have to add the shell to /etc/shells first, or you can't run a Terminal or any program that requires a shell. Oops. Chalk that one up to stupid. Fortunately, TextMate came to the rescue and I was back in business.

Or so I thought. It seems that changing my default shell didn't make any difference at all. The only thing that worked was setting COMMAND_MODE="legacy" in my /etc/bashrc, as discussed here.

Thanks, Apple. I really and truly needed to waste an entire day FAILING to reinstall all of my scripts and custom libraries so that I could WORK, over a one-line fix in an rc file.