Saturday, July 02, 2005

touch -- -i

picked up this near-blackmagic from an old followup to an old slashdot article the details of which are irrelevant here.
so here's the idea.Wait, before that, here's the situation
* you own a *nix box
* you recognise a bash when you see one
* you worked the night out
* you just typed rm -rf * or rm -rf a * or any of the umpteen incarnations of satan.
* and you hit enter
poof!
a genie appears :-) {here's where the idea comes in}

rm: remove regular file `bookmarks.bak'?

no, this is not that old sneaky alias rm='rm -i' thing that can rankle even the most patient idiot among us. it is the magic of touch -- -i . at some point in the past, when you recognised that the directory you were working in was important and you wouldn't have the will to survive an rm -rf *, you ran touch -- -i in order to tell your genie that he's screwed if he ever let you screw around that directory :)

enough of my semi-illiterate shit for now. what touch -- -i does is that it creates a file by the name '-i' in your direcotry and when in the distant future you do a rm -rf *, bash would have rewritten your command to
rm -rf ..... -i ......

and there you have it.