[comp.unix.wizards] a ksh script for safe removal

lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) (12/13/87)

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

lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) (12/13/87)

In article <3150@tut.cis.ohio-state.edu> I wrote:

> #  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.
> 
	[buggy function removed]

This doesn't work and can't work.  The set -o noglob command inside
a function doesn't work the way I thought it would.  The reason
I thought I had it right had to do with the "set"tings on my login
shell.  Sigh.

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