rt,最近使用 bash call
bash -c "custom_functions" 的方式调用自定义 shell 函数时,发现总会报一个
custom_function:command not found 的错误;然后搜了下,有三种方式解决:
- 使用
declare -fx声明 - 使用
export -fx声明 - 使用
typeset -xf声明

bash -c "custom_functions" custom_function:command not found declare -fx 声明export -fx 声明typeset -xf 声明 1 hxy100 May 15, 2023 把你的函数定义在 ~/.bashrc 这个文件中不就行了吗?每次启动新的 bash 进程都会去自动读取这个文件 |
2 OldCarMan OP 谢谢回复。不过这样会不会不大规范,毕竟代码扩散到各种地方,维护管理起来比较麻烦。 |