#! /bin/sh

goal="test regular links with 511 & 511 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 0 1 2 3 4
do
	for j in 0 1 2 3 4 5 6 7 8 9
	do
		mkdir tmpdir0${i}${j}
		cd tmpdir0${i}${j}
		path=${path}tmpdir0${i}${j}/
	done
done
mkdir tmpdir050
cd tmpdir050
touch 0101000070 a
ln a b
file1=${path}a
file2=${path}b
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
