David Kastrup [off-list ref] writes:
Instead of "grep ." one could also do something like
if read line then
while echo "$line" && read line; do :; done
die
fi
which is fork-less.
I'd agree with you that "grep ^" would be preferable _if_ we
were to do this. But in your fork-less example, you are
assuming that (1) "read" does not molest what is read, (2)
"echo" is built-in, and (3) "echo" does not munge the
parameter.
Since I am one of old fashioned shell people (I readily admit
that I used to have _fun_ with autoconf generated shell
scripts), I'd love to continue shell skill show-offs, but for
the purpose of updating this script, I would say a temporary
file is much better than any of the alternatives around 1>&3.
For one thing, it would make debugging the script while
developing and tweaking it, _and_ while using it, much more
pleasant.