Created
January 11, 2012 13:44
-
-
Save martialboniou/1594712 to your computer and use it in GitHub Desktop.
bourne shell canonical readlink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# solve the missing `readlink -f` option on OSX | |
canonical_readlink() | |
{ | |
cd `dirname $1`; | |
__filename=`basename $1`; | |
if [ -h "$__filename" ]; then | |
canonical_readlink `readlink $__filename`; | |
else | |
echo "`pwd -P`/$__filename"; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment