aboutsummaryrefslogtreecommitdiff
path: root/realpath/realpath.sh
blob: de4d964c093c72603ae1a4d1459a4897b0bfc989 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

# is there a realiable cross-platform was to do this without relying on compiling C code?

DIR=$(dirname $(readlink "$0") 2>/dev/null || dirname "$0" 2>/dev/null )
which realpath 2>&1 > /dev/null
REALPATH_INSTALLED=$?

if [ ! $REALPATH_INSTALLED -eq 0 ]; then
	if [ ! -f $DIR/realpath ]; then
	    >&2 echo "Compiling realpath" 
	    gcc $DIR/realpath.c -o $DIR/realpath
	    chmod u+x $DIR/realpath
	fi
	$DIR/realpath $1
else
	realpath $1
fi