- ##### begin building up list of bind mounts ######
- binds=() # list of bind mounts
- roots=($d) # list of bind mounts, plus the original mount
- while true; do
- new_roots=()
- for r in ${roots[@]}; do
- # eg. when r=/q/p, for lines like
- # /q/p /p none bind 0 0
- # output /p
- new_roots+=($(sed -rn "s#^$r/\S+\s+(\S+)\s+none\s+bind\s.*#\1#p" /etc/fstab))
- done
- (( ${#new_roots} )) || break
- binds+=(${new_roots[@]})
- roots=( ${new_roots[@]} )
- done
- ##### end building up list of bind mounts ######