我创建了一个脚本,将Terraform下载到我的服务器上并安装它。
ValueAnimator va = ValueAnimator.ofInt(0, getHeight());
int mDuration = 3000;
va.setDuration(mDuration);
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
Integer value = (Integer) animation.getAnimatedValue();
makeBitmapMask(value);
invalidate();
}
});
va.start();
此代码运行正常。但是一旦脚本完成并出来,#!/bin/bash
wget https://releases.hashicorp.com/terraform/0.7.0/terraform_0.7.0_linux_amd64.zip
unzip terraform_0.7.0_linux_amd64.zip
echo "export PATH=$PATH:/root/terraform_dir" >> /root/.bash_profile
source /root/.bash_profile
terraform --version
文件就会恢复原状。即路径变量未更新。
.bash_profile
当我在shell脚本之外提供echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
时,它无法正常工作。
但是,当我提交terraform --version
,然后尝试su -
时,它实际上工作正常。
是否有任何解决方法或自动脚本来更新terraform --version
。每次更新.bash_profile
时,我都不想重新开始会话?
答案 0 :(得分:1)
Shell脚本在子shell中运行(在第一行中将其定义为#!/ bin / bash),环境中的任何更改都是该子shell的本地更改,因此,bash_profile的源仅影响子shell。
要在当前shell中执行命令,请使用source命令在当前shell中运行脚本(http://ss64.com/bash/source.html)
e.g。 而不是
$ ./myscript.sh
运行:
$ source ./myscript.sh