Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 bash 环境中设置一个 http 代理(export http_proxy=xyz)。所以我将命令添加到末尾.bash_profile并调用
(export http_proxy=xyz)
.bash_profile
exec /bin/sh -c "source /path/to/.bash_profile"
但它不像预期的那样工作:$::env(http_proxy)不存在(但没有错字)。我也尝试像这样运行脚本:exec /bin/sh -c [exec cat /path/to/.bash_profile]..但结果相同。
$::env(http_proxy)
exec /bin/sh -c [exec cat /path/to/.bash_profile]
说
将source在/path/to/.bash_profile一个子外壳中。因此,当命令执行完毕时,对环境所做的任何更改都会被有效地忽略。
source
/path/to/.bash_profile
为了将环境变量传递给程序,请尝试:
exec /usr/bin/env http_proxy=xyz program