Reputation: 2080
When creating a new Bash command that has multiple words, such as remove-unused-scripts, is there a common naming convention? For instance, should it be remove-unused-scripts, or remove_unused_script, or removeUnusedScripts, or something else entirely?
I'm fairly new to Bash, just want to make sure I don't form any bad habits early on.
Thank you for your time.
Upvotes: 6
Views: 6220
Reputation: 20022
https://google.github.io/styleguide/shell.xml#Naming_Conventions suggests to use lowercase and some underscores. You can read the complete guide for more reasonable conventions, including examples.
Upvotes: 4
Reputation: 532053
I think most languages recommend remove_unused_script
over removeUnusedScript
these days for readability. remove-unused-scripts
is a legal file name for a script. bash
allows function names to contain hyphens:
some-func () {
echo hi
}
but that isn't portable; POSIX function names are restricted to letters, numbers, and _
.
Upvotes: 8