+# resolve_file [file]
+#
+# If the argument is a symbolic link, print the target of that link.
+# Otherwise, prints the basename of file.
+resolve_file () {
+ test $# -eq 1 || return
+
+ # Ensure filename won't be confused for any kind of find argument...
+ case $1 in
+ /*) :;;
+ *) set x "./$1"; shift
+ esac
+
+ find "$1" -prune \( -type l -printf '%l' -o -printf '%f' \)
+}
+