eval "export $newpath='$path'"
}
+# Remove entries which are symlinks to other existing entries.
+function canonicalisepath() {
+ local path="$1"; shift
+ local newpath=
+
+ local JGD=$IFS
+ IFS='
+'
+
+ local dirs=$(eval echo "\$$path")
+ local check=":$dirs:"
+ for dir in ${dirs//:/
+}; do
+ if [ -L "$dir" ]; then
+ # Is this a symlink to another entry?
+ local canon=$(readlink -f "$dir" 2>/dev/null)
+ if [ -n "$canon" ]; then
+ [ "${check/:$canon:/}" = "$check" ] || continue
+ fi
+ fi
+
+ newpath="$newpath:$dir"
+ done
+
+ IFS=$JGD
+
+ eval "export $path='${newpath##:}'"
+}
+
# Construct directory list, omitting nonexistent and undefined ones.
dirs=
for dir in "${SYSTEM:-@}/${ARCHITECTURE:-@}" "${SYSTEM:-@}" ""; do
[ -e "$dir" ] || continue
makepath "$var" "$dir"
done
+ canonicalisepath "$var"
else
copypath "$var" "${source#@}"
fi
done
-
-unset DIR PATHS dir dirs path var source expandpath sanitisepath copypath makepath newpath addpath
+unset DIR PATHS dir dirs path var source expandpath sanitisepath copypath makepath newpath addpath canonicalisepath