[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Upgrade to potato impossible?



> Yeah, it assumes I could actually code to save my life. And that I really
> need readlink.

 You can replace readlink with this function. I have created it for `bug'
when I discovered that realpath isn't standard (as it should).

realp()
{
	fname=${1%/}	# strips trailing '/'
	while [ -L "$fname" ]; do
		oldfname="$fname"
		fname="$(command ls -l $fname)"
		fname="${fname#*\> }"
		if [ "$fname" = . ] ; then
			fname="$(dirname $oldfname)"
		elif echo $fname | grep -vq '^/' - ; then
			fname="$(dirname $oldfname)/$fname"
		fi
	done
	pushd $(dirname $fname) > /dev/null
	fname=$(pwd -P)/$(basename $fname)
	popd > /dev/null
	echo $fname
}

Usage:

$ realp /usr/doc/libc6
/usr/share/doc/libc6
$ _


Reply to: