Re(cap): Which Unix?

Larry Wall lwall at sdcrdcf.UUCP
Thu May 16 09:25:43 AEST 1985


No, No, NO!  "Which Unix?" is almost always the WRONG question to be asking
in the first place.  "Which machine?" is usually the wrong question too.

		    **********************
		    *** Which feature? ***
		    **********************

is the right question to ask if you really and truly want to write portable
code.  If you use machine names and OS names in your #ifdefs, you are
probably only portable to the machines in use today, and then only to the
ones you know about, and then only to the ones that haven't been hacked on
by somebody.  There is SO much hybridization and cross-fertilization (did I
hear someone say "bastardization"?) going on right now in the Unix world that 
a list of machine and Unix types that differentiated all the features would
stretch from here to Pioneer 1.  Instead of saying

#if defined(bsd) || defined(pyr) || defined(vms) || defined(sun)

write something like

#ifdef CANDOIT

and then define CANDOIT in a config.h sort of file.  BUT, you say, then
I have to depend on the turkey at the other end of the wire to define or
undefine CANDOIT.

Wrongo.

Write yourself a little shell script (well, may not so little) that goes
out and checks for the feature you're interested in and writes the config.h
file itself.  This has several advantages:

    1) You don't have to depend (so much) on the turkey at the other end of
	the wire to correctly edit your config.h or (yikes!) your program. 
    2) You don't have to depend on the turkeys who wrote the system to have
	gotten their whatami.h files set up right.
    3) You don't have to try and remember which systems do or don't what.
    4) Your system will be portable to all kinds of systems you've never even
	heard of.
    5) You'll get lots of compliments on how clever you are.
    6) You get the fun of figuring out how to write the shell script, unless
	you cheat and look at Configure from the rn kit, in which case you
	get the fun of looking at Configure.
    7) You get to write funny notes like this one to those who don't know
	better.

You might be surprised how much you can find out from inside a shell script.
It's really the only way to go.  Check it out.

Larry Wall
{allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall



More information about the Comp.unix.wizards mailing list