简体   繁体   中英

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? 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.

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 _ .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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