[Vm-dev] [Unix] spaces in realpath

Bert Freudenberg bert at freudenbergs.de
Thu Apr 29 09:45:17 UTC 2010


Hi Ian,

the realpath() function in the "squeak" script does not like spaces in the path. Here is one that doesn't mind (only else-case differs):

realpath () {
    path="$1"
    while test -L "${path}"; do
	    dir=`dirname "${path}"`
	    dir=`cd "${dir}" && pwd -P`
	    path=`basename "${path}"`
	    path=`ls -l "${dir}/${path}" | sed 's,.* -> ,,'`
	    path="${dir}/${path}"
    done
    if test -d "${path}"; then
	    (cd "${path}" && pwd -P)
    else
	    dir=`dirname "${path}"`
	    file=`basename "${path}"`
	    (cd "${dir}" && echo "`pwd -P`/${file}")
    fi
}

- Bert -




More information about the Vm-dev mailing list