我的代码很简单。
variable=$( createTable $table_name )
Run Code Online (Sandbox Code Playgroud)
或者
returnedVariable=$( function $argument )
Run Code Online (Sandbox Code Playgroud)
我的代码在这一行中断。我无法在互联网上的任何地方找到如何在 Bash 中传递参数并获取返回值。
更新:我现在明白了。我的函数中不能有多个 echo。另外,echo 永远不应该被视为返回,而是可以捕获的打印语句或标准输出。感谢您的反馈!