1
考慮下面的代碼片段在函數內部:猛砸無法訪問返回代碼
local -r LSBLK_FAILED="Lsblk failed"
for f in $(lsblk -lno MOUNTPOINT "$DEVPATH"); do
sudo umount "$f";
RET=$?
if (($RET != 0)); then
echo "Unable to dismount $f - error $UNABLE_DISMOUNT_PARTITION"
return $UNABLE_DISMOUNT_PARTITION
fi
done
if [[ "$f" -eq "$LSBLK_FAILED" ]]; then
echo "Problem running Lsblk"
fi
我的問題是,我不能看到如何訪問返回代碼爲lsblk命令。我可以檢測命令是否失敗,但我無法訪問實際的返回碼。任何人都可以建議我如何做到這一點?