sh bug

Guy Harris guy at rlgvax.UUCP
Sat Oct 1 20:40:49 AEST 1983


The example

	while (something)
	do
		command <<EOF &
	This is a $test.
	EOF
	done

was incorrect; it should have read

	while (something)
	do
		command <<EOF
	This is a $test.
	EOF
	done &

This sort of loop is useful if you want to nroff a bunch of documents in
the background, the macro package has one-time actions (so you can't use
one nroff command), and you want to stick a ".po 10" command at the beginning
of each file but you see no point in 1) creating a file "/tmp/po10" or 2)
editing the documents when the next time you run them you'll only have to
take the ".po 10" out again; this is done with

for i in {the_documents}
do
	nroff {options} - $i <<EOF
.po 10
EOF
done {your_favorite_redirection}&

Unfortunately, the V7 Bourne shell, the System III Bourne shell, and the
System V Bourne shell lose on this; you either have to put the ".po 10"
into a file or run the job in the foreground.

	Guy Harris
	{seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list