This is basically Claude Code with less extra steps
Shell footgun. The
||only looks at the return value of the preceding command,rm -fr /. There’s an edge case of the command returning a non-zero error code triggering the statement intended to run if, and only if, the condition is false.[ 0 -eq 0 ] && { echo "I am in your PCs, deleting your p0rn"; false; } || echo "Lucky you?"Use
ifclauses, people. Thesetestabuses do not make one look extra-smart.On an unrelated note, I lost on the first try.
Took me a while to understand what you’re warning against. Allow me to rephrase, and tell me if I got it wrong.
The
||will execute what’s after it in two cases:- The preceding command (in this case the
rm) never ran because of an earlier&& - The preceding command ran and returned nonzero
OP’s code relies on the 1 case, but wrongly assumed that the 2 case will never happen. That’s the footgun.
- The preceding command (in this case the