如何从shell脚本设置环境变量?

hey*_*hey 13 shell-script environment-variables

我正在尝试通过 shell 脚本设置环境变量。这是使用各种技术的脚本:

#!/bin/sh
echo "export SOMEPATH=/root/some" >> /root/.bash_profile
echo "export PATH=$PATH:$SOMEPATH/bin" >> /root/.bash_profile
SOMEPATH=/root/some
export SOMEPATH
source /root/.bash_profile
Run Code Online (Sandbox Code Playgroud)

我运行该脚本a.shsh a.sh

然后,如果我检查env变量,它就不会出现。

echo $SOMEPATH什么都不返回。我希望得到SOMEPATH回报