Email or username:

Password:

Forgot your password?
1 post total
Nathan Manceaux-Panot

Just discovered in amazement that in Bash scripts, any variable named `SECONDS` will automatically increment every second. Bash is bonkers

Show previous comments
mirabilos

@Cykelero by the way, you should not define a variable in your script that’s comprised solely of uppercase letters, digits and underscore: these may be reserved by the implementation.

Environment variable names used by the utilities in the Shell and Utilities volume of POSIX.1-2024 consist solely of uppercase letters, digits, and the ('_') from the characters defined in [4]Portable Character Set and do not begin with a digit. Other characters, and byte sequences that do not form valid characters, may be permitted by an implementation; applications shall tolerate the presence of such names. Uppercase and lowercase letters shall retain their unique identities and shall not be folded together. The name space of environment variable names containing lowercase letters is reserved for applications. Applications can define any environment variables with names from this name space without modifying the behavior of the standard utilities.

(A separate location in POSIX makes this logic mostly apply to shell variables.)

So, user variables in shell scripts should always be lowercase.

@Cykelero by the way, you should not define a variable in your script that’s comprised solely of uppercase letters, digits and underscore: these may be reserved by the implementation.

Environment variable names used by the utilities in the Shell and Utilities volume of POSIX.1-2024 consist solely of uppercase letters, digits, and the ('_') from the characters defined in [4]Portable Character Set and do not begin with a digit. Other characters, and byte sequences that do not form valid characters,...

ferricoxide

@Cykelero@mas.to

Primarily working on RHEL-based (and derivative) systems, a lot of the nifty BASHisms tend to be missing because the version of BASH is typically five or more years behind current.

#Linux

Go Up