Help bourne shell problem on sun and bsd

Guy Harris guy at auspex.auspex.com
Sun Jun 9 04:07:29 AEST 1991


>    From The UNIX Programming Environment, Kernighan & Pike, pp. 159-160:
>	 --------------------------------
>
>	  " read  can only read from the standard input; it can't even
>	be redirected.  None of the shell built-in commands (as opposed
>	to the control flow primitives like  for ) can be redirected
>	with  >  or  < :

Old versions of the Bourne shell were less friendly towards redirecting
the I/O of built-in commands than later versions; perhaps K&P are
describing the old V7 version (the BSD version is pretty much the old V7
version).

>	  "This might be described as a bug in the shell, but it is a
>	fact of life.

Maybe it was a "fact of life" at the time K&P wrote that sentence - or,
at least a "fact of life" on the flavor of UNIX they were using at the
time they wrote that sentence - but it's most definitely *not* a "fact
of life" on System V Release 3.x, or systems with System V Release
3.x-derived Bourne shells, such as SunOS 4.x (nor, I suspect, on systems
with System V Release 2.x-derived Bourne shells, such as SunOS 3.x).

I don't remember whether it was a "fact of life" on System V Release 2
or not; however, since "echo" has been a Bourne shell builtin in S5 since
at least S5R2's Bourne shell, and since "echo"s standard output is often
redirected, I suspect it wasn't a "fact of life" there.

Perhaps it even works in Version 8's shell....

>So, in any environment

"*Any* environment"?  That's a pretty sweeping claim, and such claims
are dangerous to make.  Have you actually used *every* UNIX environment
other than SunOS?

In particular, SGI's environment includes an S5-based shell; did you try
the example on an SGI machine?  If so, and if it didn't work, is the
version of IRIX you used based on S5R2 or S5R3 or some earlier version
of S5?

> (with the dubious exception of Sun's),

"*Dubious* exception"?  What's "dubious" about something as useful as
being able to redirect the I/O of shell builtins?  Surely not that it
goes against the now-out-of-date claim in that version of K&P that it's
a "fact of life" that you can't redirect the I/O of shell builtins?



More information about the Comp.unix.questions mailing list