INTERCAL justifies its existence

(This is a repost. The original went of on 2010-11-14, a few hours before the spambot rape.)

Last night I made a classic n00b mistake. I was in a rush to get a test finished because my wife had just gotten home and it was time for us to haul off for the weekly Friday night with the regulars at our friendly local game store. I typed the rm -fr * to clear a scratch directory in the wrong window.

“Huh…” I thought, “that’s taking longer than it should have…” then realized with horror that it was clobbering my home directory and hastily interrupted it. Fortunately, I had a full backup on my laptop. Unfortunately, the full backup was ten days old; I stood to lose a lot of recent email and work.

Instead of gaming, I spent the next couple of hours recovering from this. I pulled the backup onto a scratch directory on my main machine, made file lists of the damaged $HOME and the backup with find(1), diffed them, and braced myself to discover how much I had irretrievably lost.

Nothing, as it turns out. I interrupted the rm -fr as it was still chewing through the alphabetically low directories under $HOME. The big one was dead.projects, my archival graveyard of superannuated stuff. When I killed it, it was busily munching on the huge directory full of tarballs and archives that I pulled together during the great INTERCAL Reconstruction Massacree.

Yes, that’s right. INTERCAL saved my butt, preoccupying the grim reaper rm just long enough

In the end, no harm done except Cathy and I didn’t get our weekly gaming debauch – I urged her to go without me but she went all wifely and supportive and stuff.

Lessons: Make backups early and often. And instead of throwing old code away, archive it where rm -fr will hit it first – because you never know, someday it might interpose its body between you and the deadliest typo.

6 thoughts on “INTERCAL justifies its existence

  1. I had mentioned in a comment to the lost post that I made a subtle but huge mistake once in the rsync command

    instead of issuing:

    rsync -avrz –del /source/dir /dest/

    I issued

    rsync -avrz –del /source/dir/ /dest/

    Which wiped the base directory of destination containing other backups. Since then I always issue the destination directory explicitly like:

    rsync -avrz –del /source/dir/ /dest/dir/

  2. Now that this post is restored, I’ll copy over what I wrote in another thread:

    Another TechTip:

    If you have a directory you’d like to protect against the Ritual of Desecration (rm -rf *), cast this Holy Incantation of Fool-Proofing:

    echo >./-i ” You dumbass. This is the `pwd` directory you’re trying to delete!”

    Then one of the first files the expansion of * turns up is the one named -i, which supersedes the previously-specified -f.

    Naming a file -f is galactically stupid, except where it’s just plain mean/i>.

  3. I realized that might happen to me, so months ago I created a directory that was guaranteed to be alphabetically first: “000aaaaaaaascrewupz.” It has 11002 files. There are some completely empty text files named simply 1-10000. Then 10001-11000 are directories, each of which contains another 1000 empty text files. Finally there is 0readme and Zreadme which explain quite courteously (to anyone who steals my laptop, I guess) what this is all for. Total is 1,010,002 text files, plus 1000 directories.

    Recently, I’ve been considering deleting this all, but you have convinced me otherwise.

  4. You are, of course, omitting the truly important question. What game were you off to play?

  5. >You are, of course, omitting the truly important question. What game were you off to play?

    I don’t usually know in advance. Given what the group has been playing lately, among the most likely would have been: Race for the Galaxy, Power Grid, Conflict of Heroes, Bohnanza, or Revolution.

  6. My habit is never to do rm -rf *; instead, I go to the parent directory and do rm -rf foo. That way, if I’m not in the directory I think I am, probably nothing happens.

    Not perfect, but it helps.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>