Bourne shell

Kenneth Almquist ka at june.cs.washington.edu
Mon May 8 14:24:28 AEST 1989


m5 at lynx.uucp (Mike McNally) asks:
> How is the BSD (version 7?) Bourne shell so small?  Did Mr. Bourne make
> a deal with the Devil, getting unreal code compactness in return for
> an eternity in a sulfurous pit where the flames never stop burnin' ya?

If so, the Devil cheated (as usual).  The Bourne shell was about 21K
bytes.  The previous version of the shell was only about 7K bytes.

The size is partly a matter of careful coding, partly a matter of
designing features so that they won't require too much space, and partly
a matter of not throwing in lots of (possibly unnecessary) features.

Consider function definitions.  Function defintions in the System V
shell are executable, so that the function definitions are parsed, and
then copied when the function definition is executed.  The code in ash
to perform this copying takes nearly 1K bytes (and this is code that
is written without any particular attention to coding style, since it
is computer generated).  If functions had been added to the shell in
the early days of UNIX, the shell language might have been redesigned
to eliminate this copy.
					Kenneth Almquist



More information about the Comp.unix.wizards mailing list