【发布时间】:2013-01-25 05:37:07
【问题描述】:
我有
#!/bin/sh
func1()
{
echo "This is func1 from shell script"
}
func2()
{
echo "This is func2 from shell script"
}
我想从 C 程序中调用 func1 和 func2。我可以这样做吗?
【问题讨论】:
-
除非您正在编写可加载的内置函数,否则不会。
-
@ormaaj 你有多确定?
-
@ormaaj 你能详细说明可加载的内置函数吗?
-
@abc Using and Writing Bash Dynamically Loadable Built-In Commands。您可以编写访问 bash 内部 API 的 C 代码,将 C 代码编译成
.sos,然后使用内置的enable将它们加载到 bash 中。