#! /bin/sh
#	Name: perform tests of the File Descriptor driver
#	Author: Mark Salyzyn	CopyRight Dec 1995
#
for i in 1 2 3 4 5 6 7 8 9 ; do
	if test -s $i ; then
		echo Too Dangerous to test >/dev/stderr
		exit
	fi
done
( echo one >&1 ; echo two >&2 ; echo three >&3 ; echo four >&4 ; echo five >&5 ; echo six >&6 ; echo seven >&7 ; echo eight >&8 ; echo nine >&9 ) >1 2>2 3>3 4>4 5>5 6>6 7>7 8>8 9>9
echo -n "If the test worked, nothing here ->"
( ls -l 1 2 3 4 5 6 7 8 9 | sed "s/^[^ ]* *[0-9]* *[^ ]* *\([0-9]*\) *.*\([1-9]\)\$/\2	\1/" ) | cmp /dev/stdin /dev/fd/4 4<<!!!
1	4
2	4
3	6
4	5
5	5
6	4
7	6
8	6
9	5
!!!
rm -f 1 2 3 4 5 6 7 8 9
echo
echo Found the following links:
echo -n "	/dev/fd/0 -> "
echo -n /dev/stdin >/dev/stdin
echo
echo -n "	/dev/fd/1 -> "
echo -n /dev/stdout >/dev/stdout
echo "		<- If empty, only because of Bug in this driver"
echo -n "	/dev/fd/2 -> "
echo -n /dev/stderr >/dev/stderr
echo
echo And the following descriptors in /dev/fd/:
ls /dev/fd | sort -n | xargs -s80 echo "        "
