我的一个 bash 脚本中有以下内容:
PID_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../pids/" && pwd )"
#...
if [ -e $PID_PATH/the_file.pid ]; then
echo "the_file was found!"
else
echo "the_file was not found!"
fi
当我回显 PID_PATH 时,它是 100% 正确的,但 if 语句一直评估为假?pids 文件夹本身是一个符号链接,我怀疑 Ubuntu 不喜欢 if 语句中的那个。
有任何想法吗?
编辑:
奇怪的是,当我使用 PID_PATH 变量作为单独的脚本(在同一路径中)单独运行 if 语句时,它可以 100% 工作吗?