我正在从make environment运行一个shell脚本
我使用输入参数作为make变量来执行脚本:
/shell_script.sh $(make_var1) $(make_var2)我在shell中处理这些变量。我想将shell命令的结果赋值给make变量,然后导出回shell。
make_var=shell_command我该怎么做呢?
发布于 2015-08-07 14:29:46
更改shell脚本的父环境并非易事,一种方法是在父环境中回显导出语句并获取脚本的输出:
...
echo "export make_var1=${make_var1}"
...当你启动你的脚本时,使用eval:
eval $(./shell_script.sh $make_var1 $make_var2)例如,这就是ssh-agent所采用的方法。
第二个选项是source脚本,在这种情况下,脚本将在当前shell中逐行运行:
. shell-script.sh脚本中的任何export语句都将在当前shell中运行。
https://stackoverflow.com/questions/31870978
复制相似问题