fixing rm * (was: Worm/Passwords)

Alex Danilo alex at megadata.oz
Thu Nov 24 17:33:28 AEST 1988


In article <1067 at entropy.ms.washington.edu>, charlie at mica.stat.washington.edu (Charlie Geyer) writes:
> Creeping featurism considered harmful.  Leave it alone.
> This is all very easy.  If you don't like rm(1) put
>   alias foo rm -i
> in your .cshrc or put a shell script foo in ~/bin
>   rm -i $*
> and use foo to remove files.
> 
This solution (& lots of others proposed) are just bodges that novice users
would learn about after the fateful 'rm * .o':-) They are also useless for
people who choose to use 'sh' instead of 'csh'.
A possibly better solution could be to destroy the utility 'rm' and make
it a built-in command in 'sh', 'csh' & 'ksh' just as 'cd' is built-in.
Whenever file(s) are removed using wildcards, the shell could simply relink
the file(s) to another unique & (almost) invisible name (i.e. prefixed by
'.') & maintain a linked list of original file names with associated hidden
name. The next command executed by the user may be either an 'unrm' or another
valid command. If 'unrm' was executed the files may simply be relinked &
restored, no harm done. Any other command (valid command that is, not a typo)
following the 'rm' can trigger the shell to unlink all the hidden file names
& achieve the same result as an intentional 'rm'. Perhaps the number of
commands that may be executed before an 'unrm' could be another environment
variable. This system is idiot-proof & saves those late night typing mistake
nightmares. The main drawback is the file space being used until the purge is
actually done. Any shell source hackers think this will slow it too much?
E PLURIBUS UNIX - alex at megadata.oz
D
D



More information about the Comp.unix.wizards mailing list