#!/bin/sh

# This script uninstalls a version (removes the version directory
# and all its contents.  If no directory is given, we remove the
# 'current' directory.

echo_no_newline()
    {
    case $bsc in
    0)
	echo -n "$@"
	;;
    1)
	echo "$@" "\c"
	;;
    esac
    }

determine_platform ()
    {
    host=`uname -n`
    arch=`uname -s`
    platform=$arch
    echo $patform
    }
 
setup_echo_statement()
    {
    case $platform in 
    SunOS)
	case `uname -a` in
	*5.*)
	    bsc=1
	    ;;
	*4.*) 
            bsc=0
	    ;;
	esac
	;;
    AIX)
        bsc=1
	;;
    HP*)
	bsc=1
	;;
    *)
        bsc=0
	;;
    esac
    }

determine_platform 
setup_echo_statement

if [ $# = 0 ]
    then
    directory=.
elif [ $# = 1 ]
    then
    directory=$1
else
    echo "Correct usage: $0 [directory]"
    exit 1
    fi

if [ ! -d $directory ] 
    then
    echo "Directory, $directory, does not exist.  Uninstall aborted."
    exit 1
    if [ ! -d $directory/bin ]
	then
        echo "Directory, $directory/bin, does not exist.  Uninstall aborted."
	exit 1
        fi
    fi

if [ "$directory" = . ]
    then
    rm_files="README Release.txt VERSION bin data"
else
    rm_files="$directory"
    fi

MESSAGE="Are you sure you want to delete $rm_files (y/n)? "

while :
    do
    echo_no_newline "$MESSAGE"
    read confirm
    case $confirm in
    [Yy])
	rm -rf $rm_files
	break
	;; 
    [Nn])
	break
	;;
    esac
    done
