#! /bin/sh

goal="test regular links with 127 & 127 character pathnames"
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 bru.out ; ../bin/rmtree tmpdir000 ; exit 1" 1 2 13 15
fi

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

rm -f bru.out
if test -d tmpdir000
then
	../bin/rmtree tmpdir000
fi

# Run test.

top=`pwd`
for i in 00 01 02 03 04 05 06 07 08 09 10 11
do
	mkdir tmpdir0$i
	cd tmpdir0$i
	path=${path}tmpdir0$i/
done
touch 0101000070 abcdefg
ln abcdefg abcdefh
chgrp 0 abcdefg
chmod 666 abcdefg
chgrp 0 abcdefg
chown 0 abcdefg
file1=${path}abcdefg
file2=${path}abcdefh
cd $top

(echo $file1; echo $file2) | $bru -cvvf bru.out -
echo "bru exit status was $?"

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

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

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

if [ "$dflag" != "on" ]
then
	rm -f bru.out
	../bin/rmtree tmpdir000
fi

exit 0
