4.3BSD-Tahoe/usr/src/man/tools/mklinks

set x $*
. ./.param

for dir in $DIRLST
do
	cd $MANDIR/man$dir
	for file in $FILLST
	do
		so=`line < $file | sed "s/ .*//"`
		if test "$so" = ".so"
		then
			continue
		else
			ed - $file > $TMPDIR/tmp.$$ <<!
				/^\.SH NAME/+s/ .-.*//p
				q
!
			name=`line < $TMPDIR/tmp.$$`
			echo $name | grep "," > /dev/null
			if test $? -eq 0
			then
				name=`echo $name | sed "s/,/ /g"`
				for ent in $name
				do
					if test $ent = `echo $file | sed "s/\..*//"`
					then
						continue
					fi
					suf=`echo $file | sed "s/.*\.\(.\{1,2\}\)\$/\1/"`
					if test ! -f $ent.$suf
					then
						cat > $ent.$suf <<!
.so $MANDIR/man$dir/$file
!
					fi
				done
			fi
		fi
	done

	rm -f tmp.$$
done