#!/bin/sh
# del by Jun Nishii <jun@vinelinux.org>
# Time-stamp: <2000-08-16 03:14:59 vine>

ShowUsage() {
cat <<EOF
Remove files after listing them.
Usage: ${1##/*/} <option> files
    option)
	-h: show this usage
	Other option is passed to rm command.
EOF
}

CheckOption() {
if [ $# = 0 ] ; then
    ShowUsage ${0##*/}
    exit -1
fi
}

for arg in $1 ; do
    case $arg in
	-h) ShowUsage; exit 0 ;;
	-*) option=$1 ;		shift	    ;;
	esac
done

CheckOption $*

FILES=`ls -dF --color=auto $* 2>/dev/null`
if [ -z "${FILES}" ]; then
	echo "no such file: " $*
	exit 1
fi
echo $FILES
echo -n "really remove them? [yiN] "
read answer
case ${answer:-"n"} in
	y)rm -f $option $* ; 	echo "ok, removed...." ;;
	i)rm -i $option $* ;; 
*) echo "canceled..." ;;
esac

exit 0