Bug fix in canonicalize() function.
authorUlrich Mueller <ulm@gentoo.org>
Mon, 30 Aug 2010 12:35:32 +0000 (14:35 +0200)
committerUlrich Mueller <ulm@gentoo.org>
Mon, 30 Aug 2010 13:23:34 +0000 (15:23 +0200)
bin/misc-functions.sh

index 6f3604d0a16d87691fc08a3902285fcf90fedae1..d7e0f568837ea9d3ff761149b97ba299be404a97 100755 (executable)
@@ -43,10 +43,10 @@ install_symlink_html_docs() {
 # replacement for "readlink -f" or "realpath"
 canonicalize() {
        local f=$1 b n=10 wd=$(pwd)
-       while [[ ${f: -1} = / && ${#f} -gt 1 ]]; do
-               f=${f%/}
-       done
        while (( n-- > 0 )); do
+               while [[ ${f: -1} = / && ${#f} -gt 1 ]]; do
+                       f=${f%/}
+               done
                b=${f##*/}
                cd "${f%"${b}"}" 2>/dev/null || break
                if [[ ! -L ${b} ]]; then