我在使用 bash 脚本时遇到了一个奇怪的问题。这里是:
PWD=${pwd}
# several commands
cd /etc/nginx/sites-enabled/
# more commands
cd $PWD
# I expect that I returning to my directory,
# but $PWD contains current dir - /etc/nginx/sites-enabled/
这种行为有点懒惰。$PWD
stores 命令,它计算当前目录并在我们调用的那一刻返回它$PWD
,但我想将字符串变量存储在其中。怎么做?