12

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?

1
  • Look like just another way of introducing "namespaces".
    – Kusalananda
    Nov 12, 2017 at 17:15

1 Answer 1

11

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.

2
  • 2
    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, 2017 at 17:27
  • @RonJohn Yeah, that's my take-away.
    – igal
    Nov 12, 2017 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .