Email or username:

Password:

Forgot your password?
Top-level
David Cantrell ๐Ÿ

@Cykelero it took me ages to track down that bug in one of my scripts a few months back. And when I say "track down" I mean "ineffectually whine for hours WHY DO YOU HATE ME? WHY IS THE COMPUTER DOING RANDOM STUPID SHIT?" until I asked someone on the internet and got an answer within approximately six seconds. Or was it seven? eight? nine? ...

11 comments
Nathan Manceaux-Panot

@DrHyde Exactly!! Their intent was good, but the implementation deeply unfortunate

Nik | Klampfradler ๐ŸŽธ๐Ÿšฒ

@DrHyde @Cykelero

Huhโ€ฆ that's a pre-defined variable counting the runtime of the script. The core issue here is that you used a reserved variable. There is exactly one variable named SECONDS, so "bash incrementing any variable named SECONDS" doesn't make much sense.

tldp.org/LDP/abs/html/internal

Nathan Manceaux-Panot

@nik Right! Thatโ€™s the technically-accurate explanation. But I think many people will write a script *thinking* theyโ€™re just creating a regular old variable, not realizing theyโ€™re stepping on a landmine of good intentions

chebra

@Cykelero The same could happen with any variable if it conflicts with a global variable. If you use variable USER, you might also not realize that it already contains a value. And the value of PWD also sometimes changes "unexpectedly".

Carl

@DrHyde Why would you do 5,6,7,8... SECONDS RTFM if you could spent hours of whining and debugging instead?! That does not seem right. @Cykelero

David Cantrell ๐Ÿ

@carl @Cykelero no normal person would expect the name of a variable to have special meaning and so think to RTFM and see if the variable name had a special meaning.

Nathan Manceaux-Panot

@carl @DrHyde pls no being mean in my mentions mister

Go Up