bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rm can accidentally delete dirs


From: Bob Proulx
Subject: Re: rm can accidentally delete dirs
Date: Sat, 8 Feb 2003 11:07:26 -0700
User-agent: Mutt/1.3.28i

Skiboo wrote:
> Toying with rm today, and came across this situation.
> You've got a file called "-n". Now, rm will interperet
> 'rm -n' as an argument (this isn't the bug). So you go
> 'rm -- -n', and everything is fine.

Good.

> However, since it tries to interperet these filenames
> as arguments, some problems come up.

Not so much problems as misunderstandings between what the command was
told to do and what the user wanted the command to do.  :-)

> Say you've got a file called '-rf', a file called
> test,  and a dir called testdir.
> 
> rm *f t*    should delete '-rf' and the  test file,

No it should not.  Your commands are not correct to get that
behavior.  Use 'echo' to see what your keystrokes are saying.

  echo rm *f t*

You will find that this says 'rm -rf test testdir'.  Put yourself in
the position of the 'rm' command.  What has the 'rm' command been told
to do in this case?

> leaving the directory, however, it interperates -rf as
> arguments, deleteing the folder and its contents. (It
> also leaves the -rf file).

Yes.  You have it exactly.  Don't do that.  You are in control.  You
have great power over the machine.  With great power comes great
responsibility.  Particularly in the case of running commands which
remove files it is good to think carefully about what you are telling
the machine to do.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]