HiveMinds / HiveMinds/Productivity-setup
Improve variable capitalisation of bash scripts.
- Dominant language
- Shell
- Stars
- 3
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Use https://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization as a reference.
A few things are important here:
- The bash software has some default variables in your system that you don't want to "accidentally overwrite".
- Nevertheless, exported variables should be all caps with underscores. (An exported variable is when you literally write something like
export JAVA_HOME="$HOME/java".) - Nevertheless, constants should be all caps with underscores. (I think technically a constant is a variable does not change after declaration. However this seems to be too broad of a scope, because often one creates a "quick/temporary" variable that is not changed simply because it is used only once, yet I think that is not a constant as intended in bash. Therefore, I think a constant is better defined as: a variable that does not change after creation and that is used across multiple scripts. I think a good example of a constant would be the hardcoded file locations of certain configuration files that may be used by multiple scripts.
- All other personal/temporary/normal variables should be in snake case.
So theoretically an issue could be that one "accidentally overwrites" the list of bash default variables (either with a exported value or a constant). To prevent this you could add a prefix to minimise the odds of accidentlly naming your exported variable/constant the same as a bash default variable. For example instead of writing OUTPUT_FILEPATH, one could add prefix LOG_ to write: LOG_OUTPUT_FILEPATH.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.