【发布时间】:2019-05-08 07:34:32
【问题描述】:
这段代码运行良好
mountpoint="/mnt/testnfs"
read -t1 < <(stat -t "$mountpoint" 2>&-)
if [ -z "$REPLY" ] ; then
echo "NFS mount stale. Removing..."
fi
如果我尝试将其放入循环中:
declare -a nfs_array=( "/mnt/testnfs1" "/mnt/testnfs2/" )
for i in "${nfs_array[@]}"
do
read -t1 < <(stat -t "$nfs_array" 2>&-)
if [ -z "$REPLY" ] ; then
echo "NFS dead"
fi
done
目的是测试所有挂载点,此代码测试并仅读取 nfs_array 中的第一个条目。如果我将 testnfs1 与 testnfs2 交换,此代码将测试 testnfs2 安装点并忘记 testnfs1 :-(
【问题讨论】: