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.
答案 0 :(得分:4)
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 _
.
答案 1 :(得分:3)
https://google.github.io/styleguide/shell.xml#Naming_Conventions建议使用小写和一些下划线。您可以阅读完整的指南,了解更合理的约定,包括示例。