【发布时间】:2021-02-16 12:37:15
【问题描述】:
我在另一个脚本 main.sh 脚本 source.sh 中调用 source.sh 脚本有以下内容
#!/bin/sh
~/.bash_profile
#main.sh has following
tar -xzvf /home/admin/perf/jdk-8u201-linux-x64.tar.gz >> /home/admin/perf/output.txt &&
sleep 1
echo "Export Path for Environmental Variable"
sudo echo "export PATH=/home/admin/perf/jdk1.8.0_201/jre/bin/:/home/admin/perf/jdk1.8.0_201/bin/:$PATH" >> /home/admin/.bash_profile
sudo echo "export JAVA_HOME=:/home/admin/perf/jdk1.8.0_201" >> /home/admin/.bash_profile
sleep 1
echo "Persisting JDK PATH to .bash_profile"
source /home/admin/perf/./source.sh
when I execute ./main.sh
#Result is ./source.sh script is not setting the export path in the same shell.
【问题讨论】: