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

Don Parris parrisdc at gmail.com
Thu Mar 15 09:30:14 CDT 2012


On Thu, Mar 15, 2012 at 05:43, Marco Tedaldi <marco.tedaldi at gmail.com>wrote:

> Hello don...
>
>
> that's a really cool Idea...
> how about "brash" (Bash tRASH)?
>
> I like it!  Very *brash* of you!  :-p


> 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).
>
> Good idea!  I started thinking about this last night as well, but have not
had time to think much about the details yet.



> 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.
>
> That's a good point.  I want to add compression, and was thinking of using
tar.  I don't really see the file attributes changing, as long as your
trash can remains in $HOME.  But I would still like to use tar, or at least
bzip or gzip to compress the trash can once it reaches a certain size.
Maybe I'll just compress it anyway.  But I do need to think about creating
unique filenames if, somehow, a duplicate file is sent to the trash bin.



> 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...
>
> That's actually another interesting idea.


>
> 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...
>
> Yes, I need to add error-checking, in case the user mis-types a filename
to delete - things like that.  I also need to figure out the best way to
handle multiple files - I'm thinking a for loop.

Should be quite fun.

Don
-- 
D.C. Parris, FMP, ESL Certificate
Minister, Security/FM Coordinator, Free Software Advocate
https://www.xing.com/profile/Don_Parris  |
http://www.linkedin.com/in/dcparris
GPG Key ID: F5E179BE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ofb.biz/pipermail/christiansource_ofb.biz/attachments/20120315/38a06291/attachment.htm>


More information about the Christiansource mailing list