What are double colons :: in a shell script?

What is double colon :: in shell scripts? like this piece of script:

 function guess_built_binary_path { local hyperkube_path=$(kube::util::find-binary "hyperkube") if [[ -z "${hyperkube_path}" ]]; then return fi echo -n "$(dirname "${hyperkube_path}")" } 

I found it here:

https://github.com/kubernetes/kubernetes/blob/master/hack/local-up-cluster.sh

+7
bash coding-style
source share
3 answers

:: is just a naming convention for function names. This is a coding style like snake_case or CamelCase

The convention for shell-style function names is usually:

Lower case with underscores to separate words. Separate libraries with ::. Brackets are required after the function name. The keyword function is optional, but it must be used sequentially by the project.

You can check here .

+7
source share

It's nothing, these colons seem to be part of the command names. You can test yourself by creating and running a command with : in the name. By default, the shell will automatically cancel them, and all this is completely legal.

+1
source share

Although Bash seems to allow colons to be placed in function names, this behavior is not standardized by POSIX .

Function names must consist of underscores, numbers, and letters from the portable set .

+1
source share

All Articles