Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!rutgers!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.UUCP (Rahul Dhesi) Newsgroups: comp.unix.wizards Subject: Re: suggest solutions for "rm *" Message-ID: <1379@bsu-cs.UUCP> Date: Fri, 30-Oct-87 08:34:56 EST Article-I.D.: bsu-cs.1379 Posted: Fri Oct 30 08:34:56 1987 Date-Received: Thu, 5-Nov-87 21:12:44 EST References: <5715@j.cc.purdue.edu> <11074@felix.UUCP> Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 104 Keywords: disaster Summary: don't alias rm to anything else In article <11074@felix.UUCP> zemon@felix.UUCP (Art Zemon) writes: >% alias rm delete I strongly advise that rm not be aliased to anything else. Instead, create a new command such as del or delete. This way you will not be rudely surprised if you ever move to a different machine and expect the aliased rm to work as before. You will also avoid confusing any scripts that use rm instead of /bin/rm. In particular, aliasing rm to "rm -i" is dangerous. You will get used to typing "rm *" and selecting files. Then one day you will type "rm *" on a different system and delete all your files. Use a different command name and tell your users they can use rm as usual and take a risk, or use del and be safer. Let them choose. Here's my del script (4.3BSD only). #!/bin/csh -f #File deletion with options #Rahul Dhesi 1987/02/25 #revised 1987/02/26 if ($#argv < 1) then echo Usage: del file ... exit (1) endif foreach file ($*) again: set type='Delete ['`/usr/bin/file "$file"|/bin/sed -e 's/ / /g'`']? [Yes/No/List/Quit] ' switch ("$type") case '*o such file or*' echo "Could not find $file" goto nextloop breaksw case '*directory*' echo "Skipping $file because it is a directory" goto nextloop breaksw case '*mission denied*' echo "Skipping $file because access to it was denied" goto nextloop breaksw endsw ask: echo -n "$type" set ans=($<) switch ("$ans") case 'y' case 'Y' /bin/rm "$file" if (-e "$file") then echo "Sorry, $file could not be deleted" | \ /bin/sed -e 's/\([^ ]\)/_\1/g' | \ /usr/ucb/more else echo "File $file" has been deleted endif breaksw case 'n' case 'N' echo "Skipping $file" breaksw case 'l' case 'L' switch ("$type") case '*text*' case '*script*' echo '*****' "$file" '*****' /bin/cat -uv "$file" | /usr/ucb/more -10d breaksw case '*empty*' echo "***** File $file is empty *****" echo '<...empty...>' breaksw case '*link to*' echo "***** Searching for printable strings in $file ... ***" /usr/ucb/strings "$file" | /bin/cat -uv | /usr/ucb/more -10dl breaksw case '*zoo archive*' echo -n "***** Archive $file contains: *****" /usr/local/zoo l "$file" | /bin/cat -uv | /usr/ucb/more -10dl breaksw default echo "***** Searching for printable strings in $file ... ***" /usr/ucb/strings "$file" | /bin/cat -uv | /usr/ucb/more -10dl breaksw endsw echo '*****' goto again breaksw case 'q' case 'Q' exit default echo 'Please type the first letter: Y, N, L, or Q' goto ask breaksw endsw nextloop: end exit -- Rahul Dhesi UUCP: !{iuvax,pur-ee,uunet}!bsu-cs!dhesi