Re:Ooops.
by JonnieCache on Thursday June 16, 2011 @10:58AM
(#2661509)
While we're on the subject, has anyone successfully found/created a replacement for rm on OS X that moves files to the trash, but doesn't break the interface of rm for use in scripts?
[ Parent
| on HN ]
Re:Ooops.
by mikemaccana on Thursday June 16, 2011 @11:13AM
(#2661583)
Normal Unix method of doing this is via LD_PRELOAD, then you wrap unlink() in something that moves things to a folder. I used something - think it was libtrash - when I used Linux on the desktop, but haven't investigated what the OS X equivalent would be.
Re:Ooops.
by neanderdog on Thursday June 16, 2011 @11:16AM
(#2661591)
rmtrash
http://www.nightproductions.net/cli.htm
I prefer 'brew install rmtrash'
Re:Ooops.
by JonnieCache on Thursday June 16, 2011 @11:19AM
(#2661604)
There's lots of stuff like that out there, I'm talking about something I can actually replace the rm binary with, a wrapper that precisely maintains the rm interface as described here: http://developer.apple.com/library/mac/#documentation/Darwin...
I like the idea of actually wrapping the unlink syscall, but I have no idea if/how darwin allows that.
You can alias trash-cli over rm, though it ignores -i, -r and -f and instead runs recursively, forced and non-interactively by default.
I use trash-cli (http://code.google.com/p/trash-cli/) on Linux, it is in Python so it shouldn't be too hard to get running on OS X (although I guess you might have to modify the location of the trash folder)