繁体   English   中英

是否有新的bash命令的命名约定?

[英]Is there a naming convention for new bash commands?

创建具有多个单词的新Bash命令(例如remove-unused-scripts)时,是否存在通用的命名约定? 例如,它应该是remove-unused-scripts,remove_unused_script,removeUnusedScripts,还是其他完全?

我对Bash很新,只是想确保我不会在早期形成任何坏习惯。

感谢您的时间。

我认为大多数语言remove_unused_script推荐remove_unused_script不是removeUnusedScript以提高可读性。 remove-unused-scriptsremove-unused-scripts的合法文件名。 bash允许函数名包含连字符:

some-func () {
    echo hi
}

但那不便携; POSIX函数名称仅限于字母,数字和_

https://google.github.io/styleguide/shell.xml#Naming_Conventions建议使用小写和一些下划线。 您可以阅读完整的指南,了解更合理的约定,包括示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM