#!/bin/csh -f
#
# $Id: delete.csh,v 1.5 1994/08/16 15:16:31 era Exp $
# $Source: /h/home/ejb/scripts/RCS/delete.csh,v $
# $Author: era $
#
# Poor substitute for delete software from Athena
#

if ($#argv < 1) goto usage

if ($argv[1] == -i) then
   set ask
   shift
endif

#
# This script does not use the -yn option to ask because it is
# paranoid.  We want anything but y to mean n rather than
# anything but n to mean y.  The default, however, must still be n.
#

foreach f ($argv)
   if (! -e $f) then
      echo "Can't delete ${f}: no such file or directory"
      goto next	
   endif
   set delete = 1
   if ($?ask) then
      set ans = `ask 5 n "delete $f?"`
      if ($ans != y) set delete = 0
   endif
   if ($delete) then
      set file = $f:t
      set dir = $f:h
      if ("$dir" == "$f") set dir = "."
      set deleted = $dir/.\#$file
      mv $f $deleted
   endif
   next:
end

exit 0

usage:

set name = $0
echo "Usage: $name:t [-i] files"
exit 1
