Search code examples
bashcoding-style

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 in here:

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


Solution

  • The :: is just a Naming Convention for function names. Is a coding-style such as snake_case or CamelCase

    The convention for Function names in shell style commonly is:

    Lower-case, with underscores to separate words. Separate libraries with ::. Parentheses are required after the function name. The keyword function is optional, but must be used consistently throughout a project.

    You can check here.