while true (was Re: Must UNIX be a memory hog?)
David Elliott
dce at Solbourne.COM
Sat May 20 03:14:57 AEST 1989
In article <2 at minya.UUCP> jc at minya.UUCP (John Chambers) writes:
>On this system, as on several others, I've replaced /bin/true and /bin/false
>with executables (which will be left as an exercise for the reader, since
>posting them would be an intellectual insult to any True Unix Wizards ;-).
>I've verified that the result is a measurable speedup in "while true"
>loops, due to the elimination of the shell startup to run an empty script.
>But this isn't much of a big deal, since such loops are rather rare.
I don't know about "rather rare", since I have a number of big
shell scripts that use "infinite" while loops.
The simplest speedup is to use a builtin command that returns
true; specifically ":". In other words, the fastest "while true"
loop is actually
while :
do
...
done
--
David Elliott dce at Solbourne.COM
...!{boulder,nbires,sun}!stan!dce
More information about the Comp.unix.wizards
mailing list