#!/bin/ksh -p
# Delete-But. Like rm but deletes everything _other_ than the specified
# files!

Rm=/usr/bin/rm
Temp=/tmp/dbtemp.$$
Cdir=${PWD}

if (( $# == 0 )) ; then
  print "Argument must be given!"
  print "(You wouldn't want me to erase all files now would you?)"
  exit 1
fi

# Make a temporary storage space
mkdir $Temp

# Extract the options for rm from the command line
opts=""
while $(( $(expr "$@ --" : "-.") )) ; do
  set -A opts ${opts[@]} ${1}
  shift
done

# Move the files we don't want to delete somewhere else
mv $@ $Temp

# Delete the files left in the directory
$Rm $opts ./*

# Bring the files back
cd $Temp
mv $@ $Cdir
cd $Cdir

# Tidy up
rmdir $Temp
