Gentoo Archives: gentoo-dev

From: Georgi Georgiev <chutz@×××.net>
To: Gentoo Devt <gentoo-dev@l.g.o>
Cc: gentoo-user@l.g.o
Subject: Re: [gentoo-dev] rm tragedies: was how to clean the "/tmp" dir
Date: Sun, 30 May 2004 03:10:55
Message-Id: 20040530031038.GA31503@lion.gg3.net
In Reply to: [gentoo-dev] rm tragedies: was how to clean the "/tmp" dir by purslow@sympatico.ca
1 maillog: 29/05/2004-20:49:21(-0400): purslow@×××××××××.ca types
2 > 040529 Simon Roby wrote:
3 > > On May 29, 2004 0527, Aaron Walker wrote:
4 > >> purslow@×××××××××.ca wrote:
5 > >>> it's always best to stop & look before hitting Enter w 'rm -rf *',
6 > >>> esp to check you are in the correct dir & know wh files/dirs are there.
7 > >> I fell victim to `rm -fr` a few weeks ago after being up 30 hr
8 > -- horrifying result snipped --
9 > > I did a `rm -rf *` in my home directory.
10 > -- horrifying result snipped --
11 >
12 > given that 'rm' automatically rejects '..' & '.' in these circumstances,
13 > it really shd also reject '/' & '~' (incl '/home/username').
14 > i wonder whether the Gentoo developers cd fix the Gentoo version to do that ?
15
16 And if someone could also code "rm" to not delete the files physically but move
17 them to the "Recycle Bin".
18
19 This was a sarcasm.
20
21 rm refuses recursive removals of "." and ".." but it still allows you to do
22 what you really may have wanted to do by running "rm -rf `pwd`" or "rm -rf
23 $(dirname $(pwd))". Recursive removals of "." and ".." are highly unlikely (one
24 usually gets out of the directory they are in before removing it) but still
25 possible to be achieved.
26
27 ~ cannot be passed as a parameter, because it is expanded by the shell.
28
29 How do you propose "rm" to prevent you from deleting stuff in your homedir? Do
30 you mean that it should warn you that the parameter you have given is your
31 homedir, or that it should be changed to warn the user who types "rm -rf *"?
32 The latter is quite impossible to accomplish.
33
34 You could use this script instead of rm if you want a safe removal tool.
35
36 #!/bin/sh
37 mkdir -p "$HOME/.Recycle Bin/"
38 exec mv -b -f -- "${@}" "$HOME/.Recycle Bin/"
39
40 --
41 (* Georgi Georgiev (* The road to ruin is always in good repair, (*
42 *) chutz@×××.net *) and the travellers pay the expense of it. -- *)
43 (* +81(90)6266-1163 (* Josh Billings (*
44
45 --
46 gentoo-dev@g.o mailing list

Replies