fixing rm * (was: Worm/Passwords)

The Grey Wolf greywolf at unisoft.UUCP
Sat Nov 26 09:27:16 AEST 1988


In article <6550 at csli.STANFORD.EDU> wagner at arisia.xerox.comP (Juergen Wagner) writes:
>In article <723 at quintus.UUCP> ok at quintus.UUCP (Richard A. O'Keefe) writes:
>>...
>>A very common practice may never-the-less be a bad idea.
>
>I agree 100%.
>
>>...
>>want to protect beginners from the dangerous commands, give them aliases
>>which flat-out refuse to do anything at all:
>>	alias rm 'echo "Use \"delete\" to delete files; rm is dangerous."'
>
>
>>...
>>No, it is _not_ a bad example.  If I "alias ls 'ls -F'", I am likely to
>>use it in a script which _relies_ on that behaviour.  Then I give it to
>>someone else and it doesn't work.  THIS KIND OF THING **HAPPENS**.
>>...
>

For one thing, csh aliases (which seems to be the format of the aliases
you are describing) are NOT EXPORTED to shell scripts OF ANY SORT.  'ls'
evaluates to whichever 'ls' is found first in your $PATH.  If you're going
to write a csh script, you're better off prefacing it with the line

#! /bin/csh -f

The reason I did that was because it saves on my startup time (it won't
read .cshrc).  All one *really* needs from one's environs to use a script is
going to be things like $PATH, $TERM, $HOME, possiblye $USER, and maybe
$LOGNAME if you're running under System V...

Now, if you're writing ksh scripts or scripts under a shell which will
support functions, and the user decides to export that function to their
environment (which can be done, I understand), the script will have to
re-define things like "ls" and "rm" to be what they should be, i.e., /bin/ls
and /bin/rm (respectively :-).

With respect to bad practice of re-defining what you want your commands
to do, it's purely a matter of opinion and subject to debate.  If I can, 
I redefine 'ls' to be '/bin/ls -A'.  If I can't, then ls is obviously
one of the braindamaged type that can't tell a file from a tty, and
redefine it to be '/bin/ls -aC'.  I'm just used to seeing things a certain
way, and if they come out different, that's my problem.
(ALWAYS type in /bin/rm from someone else's account!  point taken:  you
never know WHAT they're gonna have set up...I run my own version of rm which
follows the (evidently age-old) process of moving things to a .trash file...)

/*
VCC:		"Hey, Wo[ol]f!" | WC:				 Roan Anderson
UUCP:	   sun!unisoft!greywolf | First-name-pronounced:	       "RO-an"
CORP:	    UniSoft Corporation | ATT:			   +1 415 420 6410 168
TFTD:       "A malfunctioning machine is a sure sign of a flashing red light."
*/
-- 
...TheysaidDoyouseethebiggreenglowinthedarkhouseuponthehill?andIsaidYesIseethebiggreenglowinthedarkhouseuponthehillTheresabigdarkforestbetweenmeandthebiggreenglowinthedarkhouseuponthehillandalittleoldladyonaHoovervacuumcleanersayingIllgetyoumyprettyandyourlittledogTototoo
I don't even *HAVE* a dog Toto...



More information about the Comp.unix.wizards mailing list