335
submitted 3 months ago* (last edited 3 months ago) by HiddenLayer555@lemmy.ml to c/programmerhumor@lemmy.ml
catch {
    exec('rm -rf /*')
}
all 17 comments
sorted by: hot top controversial new old
[-] tiramichu@lemm.ee 64 points 3 months ago* (last edited 3 months ago)

Back in my days working as .NET developer on Windows 7, I came into work one morning to find a colleague fuming that his machine had died on him.

He spent the whole morning reinstalling Windows and getting his environment set back up, and then pulled the branch he was working on, happy to finally be done with setup and get back to work. Ran his test suite and bam, machine crashes!

It was only at that point the penny dropped. We took a look at his branch, and sure enough he'd accidentally written a test that, when ran, deleted his entire C: drive!

That particular lesson made me very careful when writing any code that does things with the filesystem.

[-] racketlauncher831@lemmy.ml 5 points 3 months ago

Or, you know, run it in a chroot.

[-] lowleveldata@programming.dev 46 points 3 months ago

I'm a big fan of just leaving the catch block blank as a nice fuck you gesture

[-] ikidd@lemmy.world 22 points 3 months ago

On Error Resume Next

[-] TankieTanuki@hexbear.net 21 points 3 months ago
[-] ferric_carcinization@lemmy.ml 20 points 3 months ago

No, no. You're supposed to drop tables, not throw them.

[-] nilclass@discuss.tchncs.de 5 points 3 months ago

If you drop them all the way from the top of the stack, this is what happens

[-] AstroLightz@lemmy.world 13 points 3 months ago

You got the French language initials backwards, OP.

It should be rm -fr /*

[-] lennivelkant@discuss.tchncs.de 6 points 3 months ago

Also, to make sure there are no linguistic roots left over on your system that it might grow from again, add --no-preserve-root.

[-] HiddenLayer555@lemmy.ml 5 points 3 months ago
[-] NewDark@hexbear.net 11 points 3 months ago

Seppuku exception handling is wild

[-] wise_pancake@lemmy.ca 9 points 3 months ago

Certainly nicer than my SDL experience of catch { window.becomeunclosable(); }

[-] x00z@lemmy.world 9 points 3 months ago

Having your filesystem on the line might actually make some people write decent code.

[-] sepi@piefed.social 7 points 3 months ago

Halt and catch fire

[-] ConstantPain@lemmy.world 3 points 3 months ago

The Apple way...

this post was submitted on 05 Apr 2025
335 points (99.1% liked)

Programmer Humor

37063 readers
100 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS