From: Tom P. <mlp...@ea...> - 2004-03-15 19:40:40
|
On Mar 15, 2004, at 2:16 PM, Steven Palm wrote: >> In any case, I've attached a shell script that could be used to >> replace the current BitPim python startup script. It uses a small >> shell function to extract the parent directory name from a filepath >> because the 'dirname' shell utility (like Python) is only there in >> MacOS X if the user installs the optional BSD package. Otherwise, >> it's just about line-for-line equivalent with the python version. > > I'm not interested in removing the BSD subsystem from my computer to > test, but I see you state that `dirname` is not available unless you > install the BSD subsystem. You are using `sed`, however, so that one > *is* installed? Yes, sed and awk are always installed on a minimal unix system. > Given this kind of thinking, it's probably somewhat arbitrary what > commands Apple puts on your system as a CORE package versus the BSD > package, because I would land `sed` as a part of the BSD subsystem as > well, but it apparently is not. It's understandable that this looks arbitrary to you, but it's not, really. I was surprised that there was a 'dirname' utility at all, as soon as I saw it, because I know it's not standard. That prompted me to check the Receipts directory to find which package it was installed with, and I found it was part of the BSD install. (I have a perl script that lets you search your Receipts to see who installed what, if that sounds useful. The Linux rpm system lets you ask questions like that easily, but I couldn't find anything for MacOS X that was comparable. My perl script isn't really suitable for release, IMO, because it's kind of slow - it has to reread all of the receipts each time you run the script and that's an annoying delay. It ought to cache that stuff somewhere, since it only rarely changes.) > This makes it hard to be foolproof for future OS revisions as well if > you write a shell script that depends on certain commands being there > (albeit minimal in this case. Not really. I've been dealing with cross-platform Unix issues for most of my career, and know how to write a portable Bourne shell script that you can expect to run pretty much anywhere. (Not a terribly vital job skill nowadays, unfortunately.) Sed and awk are always safe. The main challenge is recognizing and avoiding shell features that are bash- or ksh-specific. You might be surprised how much you can still do within these limitations. Cheers, Tom |