Suppose do you want test if /mnt/disk is a mount point in a shell script. How do you do this?
stat --printf '%m' shows the mount point of a given file or directory.
realpath converts relative paths to direct.
Comparing the results of the two will tell you if a directory is a mount point. stat is very portable. realpath is less so, but it is only needed if you want to check relative paths.
I'm not sure how portable mountpoint is.
if [ "$(stat --printf '%m' "${DIR}")" = "$(realpath "${DIR}")" ]; then
echo "This directory is a mount point."
else
echo "This is not a mount point."
fi
Without realpath:
if [ "${DIR}" = "$(stat --printf '%m' "${DIR}")" ]; then
echo "This directory is a mount point."
else
echo "This is not a mount point."
fi