Shell 刷新用户环境变量无效

最近在优化服务器的环境,发现我往 ~/.bash_profile 追加环境变量并通过 source 重新加载,在 sh 脚本中会产生 source 不生效的情况,在命令行中重新执行 source 是能正常的。

解决方案是重新登录。

1
su - $USER

参考:

https://stackoverflow.com/questions/4608187/how-to-reload-bash-profile-from-the-command-line

往上