我有以下 bash 脚本:
#!/bin/bash
export PYCACHED_HOST='localhost'
export PYCACHED_PORT=8001
echo "PyCached environment variables set to: PYCACHED_HOST=`echo $PYCACHED_HOST`, PYCACHED_PORT=`echo $PYCACHED_PORT`"
当我运行它时,会打印以下输出:
PyCached environment variables set to: PYCACHED_HOST=localhost, PYCACHED_PORT=8001
当我再次运行相同的回声线时:
echo "PyCached environment variables set to: PYCACHED_HOST=`echo $PYCACHED_HOST`, PYCACHED_PORT=`echo $PYCACHED_PORT`"
我得到:
PyCached environment variables set to: PYCACHED_HOST=, PYCACHED_PORT=
我知道 env vars 是为脚本上下文设置的,但是在脚本执行结束后我该怎么做才能使它们可用?