#! /bin/sh

# Note that the list of names in filelist contains an empty line, and
# that the last line is not terminated with a newline character.

goal="test strange stdin name lists"
bru=${BRU:-bru}

# Parse our args.  Options include:
#
#	-s	Print our one line test goal and quit
#

while true
do
	case $1 in
		-d)	dflag="on"
			shift
			;;
		-g)	echo $goal
			exit 0
			;;
		*bru*)	bru=$1
			shift
			;;
		*)	break
			;;
	esac
done

if [ "$dflag" != "on" ]
then
	trap "rm -f a b c d bru.out ; exit 1" 1 2 13 15
fi

# First clean up any stuff that may be left from a previous test.

rm -f a b c d bru.out

# Run test.

touch a
touch b
touch c
touch d

$bru -cvf bru.out - <filelist
echo "bru exit status was $?"

$bru -ivf bru.out
echo "bru exit status was $?"

$bru -dvf bru.out
echo "bru exit status was $?"

if [ "$dflag" != "on" ]
then
	rm -f a b c d bru.out
fi

exit 0
