Email or username:

Password:

Forgot your password?
Top-level
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

3 comments
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".

Go Up