My favourite one being
sudo rm -rf /*
What is your preferred scariest one liner code?
My favourite one being
sudo rm -rf /*
What is your preferred scariest one liner code?
For further actions, you may consider blocking this person and/or reporting abuse
Scofield Idehen -
Sukhpinder Singh -
daffodilsoftware -
Sukhpinder Singh -
Top comments (12)
The classic fork bomb is pretty terrifying:
The function is called
:
. Call itscaryFunc
instead:This function recursively calls itself, then pipes it to another call of itself that gets put in the background with
&
, meaning the child will not die and just continually recursively call itself, blocking everything else, until it's maxed out your system resources and you crash. It's even multiple-recursive, for extra oomph. After defining the function, we call it.Don't do this.
I won't do it. Pretty Scary. π±π±
The following is the Python form of one of the most insidious anti-patterns in all of programming. The scary one-liner is the third line.
Mike Pirnat aptly calls that the "Diaper Anti-Pattern". It's horrific because it silences all errors, expected and otherwise, leaving your program in an unresolved exceptional state with few, if any, clues as to what's wrong.
Always, always explicitly catch and handle (or at least log) your exceptions. Unhandled exceptions should always crash your program. Period.
From the Zen of Python:
If you're using anything resembling the diaper anti-pattern in any language, go fix it now. Seriously. Right now. Don't make me call your mother.
Here's a runner up from Python 2...
Thankfully, that one is no longer possible in Python 3.
The boolean-swapping allowed by Python 2 is a great one π I remember when I first discovered that
True
andFalse
were just builtin, mutable, global variables π¬I agree with Ben Lovy... typical forkbomb like this one in C
But even scarier is
or something like deleting the column from table in production database like:
deleting usernames is awesome. π
Watch out, a JS ghost...
Ha! Made me smile
Something I actually did. On production. But luckily before going live with a new service.
Since that day, I always BEGIN and either ABORT or COMMIT after triple-checking.
Sorry, my one liner is so scary even I'm too scared of writing it down.