Path: utzoo!utgpu!watmath!clyde!att!osu-cis!killer!convex!argos!venters From: venters@argos.uucp (Jeff Venters) Newsgroups: comp.unix.wizards Subject: Re: fixing rm * (was: Worm/Passwords) Summary: A simple solution for csh users Keywords: rm replacement alias Message-ID: <727@convex.UUCP> Date: 21 Nov 88 06:15:43 GMT References: <1232@atari.UUCP> <564@comdesign.CDI.COM> <1237@atari.UUCP> Sender: news@convex.UUCP Reply-To: venters@convex.COM (Jeff Venters) Organization: Convex Computer Corporation, Richardson, Tx. Lines: 41 Expires: Sender: Followup-To: Distribution: A simple solution for csh users: The following alias will prevent wildcard expansions. The actual wildcard characters will be passed to the script. Add the following alias to your ~/.cshrc: alias rm ~/bin/del \!\*:q Next, add the following shell script to your personal "bin" directory (or wherever you like). Obviously, the script could be made intellegent enough to recognize "-f" but it would be slower (csh is very inefficient). You could write a C-program to do this slightly faster (you would still have to fork a shell to glob the input arguments). ---- CUT HERE -------- CUT HERE -------- CUT HERE -------- CUT HERE ---- #! /bin/csh -f set nonomatch file=$0 # no wildcard matches allowed/get argv[0] set exp_names=($argv) # expand wildcards (if any) # # if the number words after globbing is not equal to the orignal, # ask for conformation. if ($#argv == $#exp_names) then /bin/rm $exp_names:q exit $status # exit script here (faster) else echo "$file:t: The following $#exp_names files will be deleted:" # show them the damage they could do /bin/ls -Fd $exp_names:q echo -n "Are you sure you want to do this (Y or N)? " if ($< =~ [Yy]) then exec /bin/rm $exp_names:q else echo "" echo "$file:t: aborted - no files deleted" exit (1) endif endif ---- CUT HERE -------- CUT HERE -------- CUT HERE -------- CUT HERE ---- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Jeff Venters, Convex Computer Corporation, Richardson, Texas Internet: venters@convex.COM | UUCP: {uiucuxc,sun,rice}!convex!venters =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=