我正在使用 ubuntu 为 travis-ci 站点设置测试环境。测试命令封装在/home/travis/test_build.sh
文件中,我尝试在其中调用设置环境变量的脚本:. ./checkout.sh
就像这里解释的那样
在执行期间checkout.sh
变量设置正确,但是当脚本完成执行时,我发现它们被设置回空(在/home/travis/test_build.sh
我真正需要它们的地方)。
在这种情况下,我该如何正确地获取脚本?我需要检查哪些设置才能启用获取脚本的功能?
简短示例 /home/travis/test_build.sh
#!/bin/bash
echo "what is 0: $0"
set -x
. ./checkout.sh
echo "COMP_ARCH=$COMP_ARCH"
echo "FRAME_BASE=$FRAME_BASE"
简短示例 checkout.sh
:
#!/bin/bash
echo "what is 0: $0"
set -e
export COMP_ARCH=slc6_amd64_gcc493
eval `scramv1 runtime -sh` # link scramv1 is set to some other script which is not mine, starts with `#!/bin/sh` and which is supposed to set some additional variables as FRAME_BASE
echo "COMP_ARCH=$COMP_ARCH"
echo "FRAME_BASE=$FRAME_BASE"
执行后的输出/home/travis/test_build.sh
将是:
what is 0: /home/travis/test_build.sh
what is 0: /home/travis/test_build.sh
COMP_ARCH=slc6_amd64_gcc493
FRAME_BASE=/home/1234/wer/base
COMP_ARCH=slc6_amd64_gcc493
FRAME_BASE=