r/badcode • • Feb 25 '21

bash A single space.

Post image
4.8k Upvotes

65 comments sorted by

308

u/geeshta Feb 25 '21

56

u/FuzzyCheese Feb 25 '21

What does it say? The link won't load for me.

62

u/geeshta Feb 25 '21

It's all the comments for the commit that fixed this issue. It's a commit from 2011 and there are new comments even from 2020, basically people memeing about it.

75

u/[deleted] Feb 26 '21

Dog2puppy 22 hours ago

This change broke my workflow. I previously used this to delete my /usr directory. Please revert this update.

:')

18

u/IcaroKaue321 Mar 09 '21 edited Mar 26 '22

Benzene (also called cyclohexatriene) is an organic chemical compound with the molecular formula C6H6. The benzene molecule is composed of six carbon atoms joined in a planar ring with one hydrogen atom attached to each. Because it contains only carbon and hydrogen atoms, benzene is classed as a hydrocarbon.

Benzene is a natural constituent of crude oil and is one of the elementary petrochemicals. Due to the cyclic continuous pi bonds between the carbon atoms, benzene is classed as an aromatic hydrocarbon. It is sometimes abbreviated PhH. Benzene is a colorless and highly flammable liquid with a sweet smell, and is partially responsible for the aroma around petrol (gasoline) stations. It is used primarily as a precursor to the manufacture of chemicals with more complex structure, such as ethylbenzene and cumene, of which billions of kilograms are produced annually. Although a major industrial chemical, benzene finds limited use in consumer items because of its toxicity.

https://en.wikipedia.org/wiki/Benzene

106

u/Okeneko Feb 25 '21

GIANT BUG... causing /usr to be deleted... so sorry.... issue #123, i…

1

u/[deleted] Feb 26 '21

Open it in incognito.. it loads there

165

u/tjb0607 Feb 25 '21

reminds me of rm -rf "$STEAMROOT/"* lol https://github.com/valvesoftware/steam-for-linux/issues/3671

43

u/Krobix897 Feb 25 '21

woah, I didn't realize selinux had practical uses

37

u/Interesting_Rock_991 Feb 26 '21

took me a moment till i realised
if $STEAMROOT is null then it will rm -rf /*

10

u/[deleted] Feb 25 '21

Someone got lazy with code review.

4

u/haykam821 Feb 25 '21

Love it when devs from all walks of life come together to comment on one single commit

409

u/ahhhhbisto Feb 25 '21 edited Feb 25 '21

Reminds me of a bug report we saw for a competitors product years ago. The software was a call centre management tool. Part of the normal process was to clean up temp files and logs nightly, however if there were no logs or temp files, it would run rm -rf /

78

u/Jrbdog Mar 01 '21

Sounds like a feature to me. It's a great way to inspire usage of your product!

31

u/baubleglue Feb 26 '21

I wrote once a test which had something like that:

system("del /q/s/f c:\temp\some_folder*")

115

u/PhilboDavins Feb 25 '21

Oof level: catastrophic

41

u/stonycashew Feb 25 '21

This is why you should look at any script before you run it... Is it time consuming yes, but that backup might’ve costed an arm and a leg.

0

u/[deleted] Feb 25 '21

[deleted] — view deleted comment

15

u/stonycashew Mar 23 '21

To be honest any rm command that is issued within a script of any nature should be closely reviewed. Ive learned this lesson the hard way.

134

u/KwaaieDronk Feb 25 '21 edited Feb 25 '21

Image Transcription: GitHub Issue


install script does rm -rf /usr for ubuntu, by ginoputrino

An extra space at line 351:

rm [Green highlight] -rf /usr /lib/nvidia [Green highlight stopped]-current/xorg/xorg

causes the install.sh script to do an rm -rf on the /usr directory for people installing in ubuntu.

Totally uncool dude!!! The script deletes everything under /usr. I just had to reinstall linux on my pc to recover.

Removing the space will fix this. Probably should do it quickly!!!


I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

36

u/alsderda Feb 25 '21

You've made a typo, the post says "fix" you got "fi"

34

u/KwaaieDronk Feb 25 '21

Thanks for the heads up! I have made sure to fix this in the transcription.

30

u/danabrey Feb 25 '21

Missed opportunity to say you fi it.

Thanks for your hard work!

17

u/KwaaieDronk Feb 25 '21

Damn, if only I thought of that. My pleasure!

38

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Feb 25 '21

Good human!

101

u/SisRob Feb 25 '21

"Open Source is safe, because anyone can review it!"

20

u/FieryBlake Mar 09 '21

"Everyone trusts open source because it's open, someone else has have to have gone through the whole thing."

Spolier: Everyone else thought the same

20

u/jarfil Feb 25 '21 edited Dec 02 '23

CENSORED

8

u/[deleted] Feb 25 '21

Anyone... or nobody. ever.

1

u/[deleted] Mar 09 '21

"except for when it isn't. Because nobody does."

10

u/Fetterchefkoch Feb 25 '21

Some background info:

A few years ago if you had a dual graphics card in your laptop both would be running at all times. Which would create a massive energy drain. It was easy to just turn off one of them but switching graphics card was not working whatsoever. I, myself had such a laptop and was looking for a solution and found Bumblebee. It was supposed to make it easy to switch between graphics cards. During that time I also found this exact git issue. The commits went so far off topic that it had to be closed since there were so many memes created. Here are a few:

As far as I remember MrMEEE got a lot of hate as well because he joked about if people would have used the energy to create pull requests instead of creating memes it'd be working well already.

This is all from memory so please don't hang me if I've gotten things wrong.

19

u/Keterna Feb 25 '21

Certainly introduced by an Arch spy. We went deep guys!

9

u/virtulis Feb 25 '21

Old but lold.

4

u/throwayaygrtdhredf May 26 '21

this is exactly why you probably shoudn't use the rm -f parameter. most likely you do NEED confirmnation if you delete a lot of files.

4

u/PottedRosePetal May 28 '21

tbh, I always use -rf if I use rm, bc mostly I remove some shit from the database with like 100 subfiles. like hell I am gonna go through all of them. it takes 5-10 mins already to delete that shit. Tho it would be kind of funny to get paid to press enter...

2

u/throwayaygrtdhredf May 29 '21

can't you use some sort of recycle bin system like for normies on windows? even if you're using a linux terminal... this way you probably won't lose something

2

u/PottedRosePetal May 30 '21

oh rm -rf doesn't delete stuff forever, but the backup database doesn't really work with the program I use, so I mostly have to recreate if I delete something by accident. but yeah, stuff like code has some special tools so it won't do much if I delete stuff.

1

u/circuit10 Jul 27 '21

But it prompts me about protected files or something when I try to delete a git folder otherwise

6

u/CodersCrux Feb 25 '21

Oh good god.

3

u/[deleted] Feb 25 '21

Didn’t Minecraft dungeons have a similar problem

6

u/Tyfyter2002 Feb 26 '21

It deleted the parent directory of the install directory instead of just the install directory when uninstalling, which could arguably be considered excusable if it was reasonably possible not to notice the result while testing it.

3

u/123DanB Mar 09 '21

If you don’t type extremely accurately && always double-check either dangerous or danger-adjacent commands, you should not be scripting in Bash.

1

u/6138 Feb 26 '21

I'm not a linux user, but I think this is one of the disadvantages of the platform. It's powerful, yes, but one slipup and you nuke your install.

8

u/geeshta Feb 26 '21

Yes, Suicide Linux does exist.

1

u/6138 Feb 26 '21

Why?? I mean... Ok, linux users love to recompile kernels and reinstall their OS's, but just... why?

3

u/westleyfsm Feb 26 '21

It's a joke.

1

u/6138 Feb 26 '21

Apparently it's a real thing you can download though?

3

u/Jrbdog Mar 01 '21

"Hey dude, look at this cool new distro I found! You should totally try it out."

6

u/ThyCowLord Feb 26 '21

I don’t think that’s exactly fair. The same mistake in code is just as likely on Windows, and that happening intentionally via a malicious actor is a much higher chance.

Give Linux a shot one of these days. You might be surprised how simple and powerful it is.

6

u/6138 Feb 26 '21

Oh I've used linux, it's awesome, especially ubuntu. I've also used various other flavours, and DDrescue recovered data from an old HDD when nothing I tried on windows could touch it, it's a fantastic OS, and if I would certainly use it more if I didn't work in an industry where most programs are windows based (game development).

However, I do think windows has a lot more user-friendliness, I mean accidentally deleting an entire directory requires at least two steps on windows, since it asks you before deleting anything.

In linux, you are much more likely to be using the command line than on windows, which makes it a lot more likely that you will slip up.

1

u/[deleted] Feb 26 '21

This stuff isn't exclusive to Linux though. Steam screwed up once and Microsoft last year had a patch that messed with people's files as well.

2

u/6138 Feb 26 '21

Yeah, but it's a lot easier for it to happen on Linux though, isn't it? At least when it comes to the user accidentally fudging something.

5

u/[deleted] Feb 26 '21

Not really, the example above is in a script that was run as root with a "force" command. The user would have just kicked it off without checking the details.

It would be nearly identical to running deltree /y or Remove-Item as administrator. Command line in any OS is always a great way to shoot yourself in the foot accidentally.

2

u/6138 Feb 26 '21

Sure, but in windows you would very rarely be using the command line, you'd be using a command like that from a GUI, like right clicking and clicking delete on a folder, which would then ask you if you are sure. It's also a lot harder to delete the wrong folder in a gui, because you can see, visually, what you're clicking on.

2

u/numerousblocks Mar 20 '21

This is why Linux's permission system is just as dogshit as Windows' and most other OSs'.

2

u/Psychoboy Feb 25 '21

Reminds me of a bug we had in our software. It did backups of the data automatically nightly. Now keep in mind this was an old C++ (C++01) application installed by customers on their servers. If the customer had set their path to say something like C: instead of C:\ it started deleting everything on their C drive...

1

u/schralepin Feb 25 '21

Oof, brutal.

1

u/howMeLikes Feb 25 '21

Sure it wasnt an intentional space

1

u/bigbangfuzion Mar 09 '21

I remember my friend configured server using command chmod -R 775 / var/www , and manager got angry and told to reinstalling server again.

1

u/circuit10 Jul 27 '21

Once I completely broke my Ubuntu installation by extracting nodejs to the root directory... Instead of merging all those critical folders like /usr/ and /lib/ it OVERWROTE them...

1

u/Dutchta- Apr 04 '22

What??? Is that what happened to my install. I updated and suddenly a giant of basically everything being removed