bash – shell脚本中的双冒号::

前端之家收集整理的这篇文章主要介绍了bash – shell脚本中的双冒号::前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
什么是双冒号::在 shell脚本中?像这块脚本:
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}")"
}

我在这里找到了它:

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

::只是函数名的命名约定.是编码风格,如 snake_caseCamelCase

shell样式中函数名的约定通常是:

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.

你可以查看here.

猜你在找的Bash相关文章