Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 424
SemperCallide Avatar asked Dec 18 '22 18:12

SemperCallide


1 Answers

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

like image 184
chepner Avatar answered Jan 02 '23 18:01

chepner