From: Richard Emberson <remberson@ed...> - 2003-04-21 19:23:33
The following shell function converts all of the symbolic links in a
path into their "real" directories:
# remove all links
declare l=`echo $path | sed -e 's;/; ;g'`
for c in $l; do
while [ -h "$rpath" ] ; do
ls=`ls -ld "$rpath"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
# ant is a symbolic link
# this echos "/home/emberson/java/jakarta/apache-ant-1.5.3-1/lib"
Great I would not have come up with that on my own. I was able to
modify the sh and bash scripts based on the function you sent so that
the scripts now work perfectly without using the realpath utility at all.
I did have to modify things slightly so that the scripts would work
correctly when called with a relative path.
The new scripts seem to work for all circumstances that I tested so
far. If you an others could once again take a look at them and make
sure they work on your environments, I would appreciate it.
Now that these scripts no longer need the realpath utility, I would
like to remove it from the distribution. One concern is that this could
break some peoples' build scripts which are expecting the file to be
there. But they will have to be fixed at some point even if I defer
pulling the utility out, so unless I hear any major objections, I'll go
and remove it.