[英]Is there a naming convention for new bash commands?
When creating a new Bash command that has multiple words, such as remove-unused-scripts, is there a common naming convention? 创建具有多个单词的新Bash命令(例如remove-unused-scripts)时,是否存在通用的命名约定? For instance, should it be remove-unused-scripts, or remove_unused_script, or removeUnusedScripts, or something else entirely? 例如,它应该是remove-unused-scripts,remove_unused_script,removeUnusedScripts,还是其他完全?
I'm fairly new to Bash, just want to make sure I don't form any bad habits early on. 我对Bash很新,只是想确保我不会在早期形成任何坏习惯。
Thank you for your time. 感谢您的时间。
I think most languages recommend remove_unused_script
over removeUnusedScript
these days for readability. 我认为大多数语言remove_unused_script
推荐remove_unused_script
不是removeUnusedScript
以提高可读性。 remove-unused-scripts
is a legal file name for a script. remove-unused-scripts
是remove-unused-scripts
的合法文件名。 bash
allows function names to contain hyphens: bash
允许函数名包含连字符:
some-func () {
echo hi
}
but that isn't portable; 但那不便携; POSIX function names are restricted to letters, numbers, and _
. POSIX函数名称仅限于字母,数字和_
。
https://google.github.io/styleguide/shell.xml#Naming_Conventions suggests to use lowercase and some underscores. https://google.github.io/styleguide/shell.xml#Naming_Conventions建议使用小写和一些下划线。 You can read the complete guide for more reasonable conventions, including examples. 您可以阅读完整的指南,了解更合理的约定,包括示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.