[Gllug] Re: Bizarre shell behaviour

Per Gregers Bilse bilse at networksignature.com
Fri Nov 7 21:09:30 UTC 2003


Everybody's right -- it's the sh programmers nightmare.

In the early days of UNIX, /bin/sh would take up no more than half a
dozen k on eg a PDP-11, and that was before shared libraries.  Voluminous
constructs like a loop (shock, horror) were run as subprocesses, as
code to handle nesting was considered too large to warrant inclusion in
/bin/sh itself; that is, /bin/sh would handle only one, flat block of
code (or script, if you wish), and the notion of blocks was implemented
with forks and pipes, in varying degrees.  The result is that global
variables are not necessarily global inside a block.

The same philosophy applied to other shell things, and many people are
surprised to learn that eg test(1) has only recently become a built-in.
Fun: see if your system has '/usr/bin/[' or '/bin/['; most/all have it,
for backwards compatibility.

Over the years more and more things were integrated into the shell
itself, and different flavours have done different things with sub-block
variables: either stay backwards compatible, or do the apparently
obvious thing.  Either way, somebody will lose.

  -- Per


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list