view tools/rootup.sh @ 497:7b0ae8e8ab80

Remember about old readlink, which can't do `readlink -f`. Pointed out by: tinderbox
author Aleksandr Rybalko <ray@ddteam.net>
date Tue, 13 Aug 2013 14:11:55 +0300
parents d5a47dc8d6a1
children
line wrap: on
line source
#!/bin/sh

SRCPATH=$1

if [ -x /bin/realpath ] ; then
	REALPATH="realpath"
else
	REALPATH="readlink -f"
fi

ROOTUP="/.."
_FOR_ROOTUP=`echo ${SRCPATH} | sed 's/\// /g'`
for r in ${_FOR_ROOTUP}; do
	_ROOTUP_TEST=`${REALPATH} ${SRCPATH}/${ROOTUP}`
	if [ "x${_ROOTUP_TEST}" != "x/" ] ; then
		ROOTUP="${ROOTUP}/.."
	fi
done


echo ${ROOTUP}