subdir=
findopt=
cpioopt="-p"
typeset -Z2 mon day year hour min
eval `date '+mon=%m day=%d year=%y'`
dstr=
hour=00
min=00
arg=
farg=
last=
lcmd=
while true
do case "$1" in
	'')		break;;
	/[sS])		findopt="$findopt -depth"; cpioopt="${cpioopt}d"
			subdir=Y;;
	/[mM])		cpioopt="${cpioopt}m";;
	/[aA])		cpioopt="${cpioopt}u";;
	/[pP])		;;
	/[lL]:*)	logfile=${1#*:}
			logfile=${logfile:-BACKUP.LOG}
			lcmd="tee -a $logfile |";;
	/[tT]:*)	hstr=${1#*:}
			hour=${hstr%%[.:]*}
			hstr=${hstr#*[.:]}
			min=${hstr%[.:]*}
			;;
	/[dD]:*)	dstr=${1#*:}
			mon=${dstr%%[-/]*}
			dstr=${dstr#*[-/]}
			day=${dstr%[-/]*}
			year=${dstr#*[-/]}
			;;
	*)		if test -f "$1"
			then	arg="$arg $1"
				last=
			else
				farg="${farg} ${last}"
				last="$1"
			fi
			;;
   esac
   shift
done
if test -n "$dstr$hstr"
then
	trap "rm /tmp/dsh$$" 0
	trap exit 1 2 3 15
	touch "${mon}${day}${hour}${min}${year}" /tmp/dsh$$
	findopt="$findopt -newer /tmp/dsh$$"
	if test "$arg" != ""
	then	temp=`ls -t /tmp/dsh$$ $arg`
		arg=${temp%?/tmp/dsh$$*}
		if test "$temp" = "$arg"
		then	print - "Nothing to backup"
			rm /tmp/dsh$$ ; exit 1
		fi
	fi
else	arg=`ls $arg`
fi
if test ! -d "$last"
then
	print - "$0: Error - no directory specified for backups"
	exit 2
fi
if test -n "$lcmd"
then
	/bin/date "+%D %T To $last:" >>$logfile
fi
if test -n "$subdir"
then
	_Ducmd "find $farg $findopt -print | $lcmd cpio $cpioopt $last"
else
	_Ducmd "echo \"$arg\" | $lcmd cpio $cpioopt $last"
fi
