The old code didn't work on Mac OS X, as "which" returns successfully when it can't find the program.