V2EX › Bash
使用 shell 的 bash -c "functions"时,是不是所有相关的函数都得声明出来?
By OldCarMan at 2023 年 3 月 15 日 · 2438 次点击rt,最近使用 bash call
bash -c "custom_functions"
的方式调用自定义 shell 函数时,发现总会报一个
custom_function:command not found
的错误;然后搜了下,有三种方式解决:
- 使用
declare -fx声明 - 使用
export -fx声明 - 使用
typeset -xf声明