6

The Google bash style guide mentions bash packages, where the package name should be separated from the function name by double colons

If you're writing single functions, use lowercase and separate words with underscore. If you're writing a package, separate package names with ::. Braces must be on the same line as the function name (as with other languages at Google) and no space between the function name and the parenthesis.

# Single function
my_func() {
  ...
}

# Part of a package
mypackage::my_func() {
  ...
}

I've googled but found no references to bash packages except for the Lightweight bash Package Manager. Is that what they're referring to?

  • Look like just another way of introducing "namespaces". – Kusalananda Nov 12 '17 at 17:15
4

I don't think that Bash has any built-in support for packages in the way that "real" programming languages do. It's probably just a naming convention used to mimic namespaces for the purposes of code organization. See the following post for further discussion:

I imagine it was inspired by the syntax used for Perl modules.

  • As if you put a bunch of functions in mylib.sh all being prefixed with mylib:: and then source that file at the top of your "end user" scripts. IOW, home-rolled namespaces? – RonJohn Nov 12 '17 at 17:27
  • @RonJohn Yeah, that's my take-away. – igal Nov 12 '17 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.