[CS-FSLUG] Bashing the Trashman - A Trash Can For Bash

Marco Tedaldi marco.tedaldi at gmail.com
Thu Mar 15 04:43:29 CDT 2012


Hello don...

On 14.03.2012 19:43, Don Parris wrote:
> I wouldn't call myself much of a hacker (programmer), but I finally found a
> project interesting enough to me to learn bash scripting:
> 
> http://dcparris.net/2012/03/14/bashing-the-trashman-trash-can-for-bash-shell/
> 
> Throw your rotten tomatoes - or money if you like.  :-p  All in good fun
> and for learning, but I do welcome comments.

that's a really cool Idea...
how about "brash" (Bash tRASH)?

A few Ideas:
Implement a way to avoid collisions when two files have the same name
(either check before moving and append some numeric to the filename if
there is already a file with the same name or make up a new filename
everytime, since you have the original filename in the logfile anyway).
I'd suggest creating a new unique filename everytime (for example with
the timestamp or use mktemp (which is used to make unique filenames for
temporary files but could be used here as well i think).

Use tar to put the file into the trash. that way, all the file
properties (like owner, creation timestamp and permissions) can be
restored as well. Sure, mv is WAY faster especially as long as the file
is on the same filesystem as the trashcan-directory.

Add a function to delete single files (or groups of files) from the
trashcan.
For example:
trash purge [filename]

Just a few of my crazy ideas...


And you really got me thinking about how to implement the handling of
multiple files the easiest way. But as far as I can see you already did
a great job in making functions out of everything, so including multiple
file handling should not be a huge deal...

shalom

Marco




More information about the Christiansource mailing list