#!/bin/sh

## Alternate for the old 'install' program which could understand the
#  good old syntax-  'install -c -m <mode> file file file dest
# Dunno why these OS folks had to change things so drastically!!
#
#	-vikas@navya.com
#

MODE=755

# I run the check for '-m' twice in case its been specified after -c option
#
if [ "$1" = "-m" ]; then
	MODE=$2
	shift ; shift
fi
if [ "$1" = "-c" ]; then
	shift ;		# ignore
fi
if [ "$1" = "-m" ]; then
	MODE=$2
	shift ; shift
fi

###
###
if [ $# -eq 0 ]; then
	echo "Nothing to install"
	exit 1
fi

while [ $# -gt 1 ]
do
	FILES="$FILES $1"
	shift
done

DEST=$1

echo "myinstall:  Installing $FILES  to  $DEST"

if [ -d "$DEST" ]; then
	for F in $FILES ; do
	  rm -f $DEST/`basename $F`
	  cp $F $DEST
	  chmod $MODE $DEST/`basename $F`
	done
else
	if [ -f $DEST ]; then
	  rm -f $DEST
	fi
	cp  $FILES   $DEST
	chmod $MODE  $DEST
fi
