"Invalid null command"
Dick Dunn
rcd at ico.isc.com
Tue Apr 2 10:56:20 AEST 1991
Bourne shell users, accustomed to creating or emptying a file with a
command like:
>splot
or rewinding a tape with:
</dev/mt0
are occasionally annoyed to find that csh rejects this syntax with the
confusing message "Invalid null command". (It is confusing because there
is no such thing as a *valid* null command; attempts to find one will only
end in frustration.)
This can be solved as follows:
touch /bin/IEFBR14
chmod 755 IEFBR14
The name is chosen for historical relevance, since most of us who still
use the Bourne shell are Luddites or recidivists anyway. Of course,
IEFBR14 >splot
seems a bit naked without some slashes and an EXEC PGM=, but that's the
way these modern systems are...
Some folks may note a more-than-coincidental resemblance between this
version of IEFBR14 and older versions of /bin/true. So it is, but our
example lacks the sophistication of the modern System V "true" command,
which is now 9 lines long and includes
- an entirely superfluous :
- five lines of copyright notice (so don't y'all go trying to use
empty files any more; AT&T owns the copyright)
- a #ident--which, of course, is meaningless to the shell, but
reveals the interesting fact that we're now up to version 2.3
of a formerly-empty file
However, the preceding was only for illustration anyway. Nobody wants a
dirty old shell script for the null command; it should of course be a C
program for efficiency. So here we have the first cut at IEFBR14.c:
main()
{
}
This also serves only for illustration; it is historically accurate in that
it contains the same bug as IBM's original IEFBR14. (It may be of some
interest that IEFBR14 proved the old CS aphorism "Every program contains
at least one bug and can be shortened by one instruction" at the inductive
limit: It was a single instruction which didn't work...but I digress...)
Here's the first correction:
main()
{
exit(0);
}
But to make this proper in today's brave new world, we need <stdlib.h>.
Also, for formality's sake and international propriety, we should add the
normally-obligatory setlocale() call (actually not necessary--this may be
the *only* program for which that's true--but it's hard to pass up poking
fun at a requirement to set a default explicitly), and this in turn
requires <locale.h>. OK, so here's the penultimate version of IEFBR14.c,
our properly ANSI and internationalized (unless I screwed up) program-to-
do-nothing:
#include <stdlib.h>
#include <locale.h>
#ifndef lint
static char *sccsid = "%W% - %E%";
#endif
/*ARGSUSED*/
main(argc,argv)
int argc;
char **argv;
{
setlocale(LC_ALL, "");
exit(0);
}
To create the final version, all you need is your local draconian
corporate screenful of copyright notice and disclaimer.
--
Dick Dunn rcd at ico.isc.com -or- ico!rcd Boulder, CO (303)449-2870
The Official Colorado State Vegetable is now the "state legislator".
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list