read in /bin/sh appears to be VERY cpu costly.

George Michaelson ggm at brolga.cc.uq.oz.au
Wed May 8 11:30:13 AEST 1991


I have written a very crude shellscript to do while loops over a read
command. This is to permit a user attached to a terminal that cannot
do control characters (!) to get access to unix and do some useful stuff
with MH and editors.

I have just found out she incurred around 300 seconds of CPU time on a
sun 4 in 1 login session.

simple tests using time on a shellscript of:

	while 1
	do
		read INP
		echo $INP
	done

seem to suggest that read is incredibly expensive on the CPU.

Is this true, and is there any "cheaper" way to do interactive input
from a terminal within shellscripts?

Is this a "feature" in SunOS 4.1.1 /bin/sh?

	-George
-- 
	G.Michaelson
Internet: G.Michaelson at cc.uq.oz.au                     Phone: +61 7 365 4079
  Postal: George Michaelson, the Prentice Centre,
          The University of Queensland, St Lucia, QLD Australia 4072. 



More information about the Comp.unix.shell mailing list