This repository has been archived on 2022-02-20. You can view files and clone it, but cannot push or open issues/pull-requests.
bash-shell-base/modules/utility/filesystem.mod

18 lines
440 B
Bash

#!/bin/bash
# must be json as a string, depends on jq
mounted () {
[[ ! $1 ]] && echo no mount point to test && return 2
mountpoint "$1" &> /dev/null && echo yes || return 1
}
# peals back sub-directories until if finds a mountpoing
find_mountpoint () {
local dir=$1
if [[ ! $dir = "/" ]]; then
# echo trying $dir for mountpoint
[[ $(mounted $dir) ]] && echo $dir || find_mountpoint "$(dirname $1)"
else
return 1
fi
}