- # we sort the list according to destination so we're sure that we won't hide a previous mount. we also ignore duplicate destinations in a more or less arbitrary way
- sort -k2 -sbu ${bindings} -o ${bindings}
+ # We sort the list according to destination so we're sure
+ # that we won't hide a previous mount. We also ignore
+ # duplicate destinations in a more or less arbitrary way.
+ [ -e "${bindings}" ] && sort -k2 -sbu ${bindings} >> ${custom_mounts}
+ rm -f ${bindings}
+
+ # After all mounts are considered we add symlinks so they
+ # won't be hidden by some mount.
+ [ -e "${links}" ] && sort -k2 -sbu ${links} >> ${custom_mounts}
+ rm -f ${links}