LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   emulating "rm " command (https://www.linuxquestions.org/questions/linux-software-2/emulating-rm-command-790009/)

unSpawn 05-31-2010 04:58 PM

What you should do is put rm back to where it was and forget using aliases or scripts like yours. Aliases can evaded, don't cover applications removing files and scripts can behave unexpectedly. besides replacing a system binary with a kludge isn't standards compliant anyway.

Re-inventing the wheel was done before, see: http://directory.fsf.org/project/trashcan/, http://sourceforge.net/projects/rmw/, http://code.google.com/p/safe-rm/, http://www.linuxquestions.org/questi...8/#post3564350.

Libtrash intercepts syscalls through LD_PRELOAD. From the README: "libtrash works with any GNU/Linux program, both at the console and under XFree86, and operates independently of the programming language the program was written in. The only exception are statically linked programs, which you probably won't find. It can be extensively configured by each user through a personal, user-specific configuration file." (Also see http://www.linuxquestions.org/questi...9/#post3453347.)

There also is ext3cow (but I don't know how it fares right now) and then there's versioning filesystems.

salasi 06-01-2010 05:11 AM

Quote:

Originally Posted by unSpawn (Post 3987860)
What you should do is put rm back to where it was and forget using aliases or scripts like yours.... besides replacing a system binary with a kludge isn't standards compliant anyway.

I completely agree on that part, but

Quote:

Originally Posted by unSpawn (Post 3987860)
Aliases can evaded, don't cover applications removing files and scripts can behave unexpectedly.

I think that is one case in which something like this (not this, exactly, but something along similar lines) can make sense; if you are concerned about 'finger trouble' with a powerful command like 'rm -Rf' and variants thereof, then aliasing it to something that gives you a second chance can make sense (of course, you can also argue that someone who is not in control of what their fingers do shouldn't be in possession of a computer...not that I would make this argument, you understand).

If, of course, you replace a system binary, that changes things for all users; that seems sub-optimal.

Personally, I won't take any code seriously that is not in code tags or otherwise formatted for easy reading, because that means that the OP hasn't taken the effort to make it easy to read; why should hundreds of people have to make that effort because one didn't do it correctly? But, you'll have got exit codes wrong, everyone does.

So, when you try to update, uninstall or install software, expect the system not to perform the procedure correctly. In some cases, it will only be trivially different from a correct procedure, and the system will still work correctly. In others it won't.

Have Fun!

jaikris 06-08-2010 02:23 PM

am using " tar -cvf <destination > source > /dev/null " for the new command ( rm - emulation )

evan after am redirectig the output message , still am receiving the message : tar: Removing leading `/' from member names

how to avoid the message from screen

cantab 06-22-2010 04:44 AM

Try 2&> /dev/null to redirect stderr as well. Bear in mind you're then sending stuff that might be important - tar telling you it's gone wrong - to the bit bucket.


All times are GMT -5. The time now is 12:36 AM.