在 google 的 shell style guide 中,我们可以看到 package 这一部分。
# Single function
my_func() {
…
}
# Part of a package
mypackage::my_func() {
…
}
而且我在 k8s 的 shell 代码中看到大量的这种用法:
function kube::util::sourced_variable {
# Call this function to tell shellcheck that a variable is supposed to
# be used from other calling context. This helps quiet an "unused
# variable" warning from shellcheck and also document your code.
true
}
kube::util::sortable_date() {
date "+%Y%m%d-%H%M%S"
}
https://github.com/kubernetes/kubernetes/blob/master/hack/lib/util.sh
可是当我自己去使用这种风格编写代码的时候
utils::curl() {
echo "curl"
}
utils::curl
I got an error util.sh: line 11: `utils::curl’: not a valid identifier
是不是太明白这个风格的 shell 是需要什么配置还是我哪里写错了。