this post was submitted on 02 Aug 2026
179 points (95.9% liked)
linuxmemes
32332 readers
462 users here now
Hint: :q!
Sister communities:
Community rules (click to expand)
1. Follow the site-wide rules
- Instance-wide TOS: https://legal.lemmy.world/tos/
- Lemmy code of conduct: https://join-lemmy.org/docs/code_of_conduct.html
2. Be civil
- Understand the difference between a joke and an insult.
- Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
- Don't get baited into back-and-forth insults. We are not animals.
- Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
- Bigotry of any kind will not be tolerated. This is an LGBTQ+-friendly community -- if that is a problem for you, you should leave.
3. Post Linux-related content
- Including Unix and BSD.
- Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of
sudo in Windows.
- No porn, no politics, no trolling or ragebaiting.
- Don't come looking for advice, this is not the right community.
4. No recent reposts
- Everybody uses Arch btw, can't quit Vim, <loves / tolerates / hates> systemd, and wants to interject for a moment. You can stop now.
5. ๐ฌ๐ง Language/ัะทัะบ/Sprache
- This is primarily an English-speaking community. ๐ฌ๐ง๐ฆ๐บ๐บ๐ธ
- Comments written in other languages are allowed.
- The substance of a post should be comprehensible for people who only speak English.
- Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
6. (NEW!) Regarding public figures
We all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations.
- Keep discussions polite and free of disparagement.
- We are never in possession of all of the facts. Defamatory comments will not be tolerated.
- Discussions that get too heated will be locked and offending comments removed.
ย
Please report posts and comments that break these rules!
Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.
founded 3 years ago
MODERATORS
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.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:rm) never ran because of an earlier&&OP's code relies on the 1 case, but wrongly assumed that the 2 case will never happen. That's the footgun.
||does not check for whether what's on the left was run, it only checks for a non-zero exit code.In this case the left operand for
||is&&, not thermcommand. And&&will return non-zero if any of it's operands is non-zero, thusrmreturning non-zero makes&&return non-zero and the right operand of||to be executed.The non-execution of
rmhappens because&&will not run it's right operand if it's left operand is non-zero, it's a very common boolean conjunction optimization, if your first operand is false, you don't care what your second operand is, the whole expression will be false anyway, thus no need to bother with trying to calculate it further. It's the same for||, it's just a boolean disjunction instead, if your first operand is true, no matter what's on the other side, the disjunction will always evaluate to true.Nah, we just abuse it even more.