Path: utzoo!utgpu!water!watmath!clyde!cbosgd!osu-cis!tut!lvc
From: lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani)
Newsgroups: comp.unix.wizards
Subject: a ksh script for safe removal
Keywords: globbing
Message-ID: <3150@tut.cis.ohio-state.edu>
Date: 12 Dec 87 19:02:30 GMT
Organization: Ohio State Computer & Info Science
Lines: 39

Here is a Korn shell function I wrote for safe file removal.
I suppose it can be done is csh too.

If the arguments are wildcards it asks if you really want to
remove the files.  Type in y to proceed.  A delete or any non-y
character to not do it.

Now can we stop debating about globbing in the shell please.

-------------------------------cut here-------------------------
#  This function checks if the arguments to it contain shell
#  wildcards.  If so, it asks the user if they really want to
#  proceed to remove their files named.  If there are not wild
#  cards it just proceeds to remove them.

function callitwhatyouwant
{
    set -o noglob
    x='echo eval $*'

    set +o noglob
    y=$*

    if [ "$x" != "$y" ]
    then
	echo really: $y
	read response
    fi

    if [ "y${response#y}" = "${response}" ]
    then
	/bin/rm $y
    fi
}
------------------------------cut here--------------------------

-- 
	Larry Cipriani AT&T Network Systems at
	cbosgd!osu-cis!tut!lvc Ohio State University