was building around `readlink -e` myself until I found out somebody on [stackoverflow][1] actually had the same problem and some working solution, too. (Found it after I realized having problems with pwd not resolving symlinks in folders - had written essentially the same code apart from whitespace and variable naming…)
Just put the script somewhere in BaseX' scripts folder and replace `readlink -e` by this script. Completely based on POSIX commands and options, so should work on all UNIXes.
#!/bin/sh
TARGET_FILE=$1
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=`readlink $TARGET_FILE`
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
PHYS_DIR=`pwd -P`
RESULT=$PHYS_DIR/$TARGET_FILE
echo $RESULT
--
Jens Erat
[phone]: tel:+49-151-56961126
[mail]: mailto:email@jenserat.de
[jabber]: xmpp:jabber@jenserat.de
[web]:
http://www.jenserat.de
PGP: 350E D9B6 9ADC 2DED F5F2 8549 CBC2 613C D745 722B
Am 25.10.2011 um 14:44 schrieb Christian Grün:
> Ralf,
> thanks for the proposal - nitpicks are welcome as well ;) Before
> applying the changes, I'd like to have some feedback from Mac users,
> though.. Did someone try the alternative script?
>
> Christian
> ___________________________
>
> On Mon, Oct 24, 2011 at 8:06 PM, Ralf Jung
ralfjung-e@gmx.de wrote:
>> Hi,
>>
>> thanks a lot for this, the recent optimizations are really appreciated :D
>>
>> Just one minor nitpick is left, from my side... if I create a symlink to one
>> of the scripts in bin/, it stops to work. This is caused by the script looking
>> for its class files in the folder the script is in, without taking symlinks
>> into account. It can be fixed by replacing the PWD= line in each script with
>> the following
>> PWD="$(dirname "$(readlink -e "$0")")"
>>
>> However, the -e option of readlink is a GNU extension, so non-Linux UNIXes
>> (most notably Mac OS) will probably not support that option. If you want to
>> support those OSes, it gets a bit more complicated, one could do something
>> like this (which I did not test):
>>
>> if readlink -e . &> /dev/null; then
>> # readlink supports -e, use it
>> PWD="$(dirname "$(readlink -e "$0")")"
>> else
>> # readlink does not support -e (e.g. Mac OS)
>> # do not support being called through symlinks
>> PWD="$(dirname "$0")"
>> fi
>>
>> With some shell magic it might also be possible to follow symlinks on Mac, but
>> honestly I don't care enough about Mac to look into that ;-) . This keeps the
>> status quo on Mac (and others), and makes things better on Linux.
>>
>> Kind regards,
>> Ralf
>>
>> On Sunday 23 October 2011 21:48:03 Christian Grün wrote:
>>> Hi all,
>>>
>>> we are glad to announce BaseX 7.0.1, which is basically the result of
>>> your initial feedback on 7.0. Those are the most important changes:
>>>
>>> DISTRIBUTIONS:
>>> - Windows installer was updated to support latest features
>>> - ZIP file was updated (initial config & directories added)
>>> - Short directory names are chosen if config file resides in app.dir.
>>> - Start scripts have been improved
>>>
>>> XQUERY:
>>> - much faster execution of count() when applied to opened databases
>>>
>>> SERVER (
http://docs.basex.org/wiki/Startup_Options#BaseX_HTTP_Server):
>>> - Flag -c connects to an existing database server
>>> - Flag -s specifies a port for stopping the HTTP server (Jetty)
>>> - Flag -S starts the HTTP server as a service
>>> - running write operations will be completed before server is stopped
>>>
>>> API:
>>> - Ruby, Python, PHP, Java: clients updated
>>>
>>> Please check out the well-known links:
>>>
>>> - Homepage:
http://basex.org/
>>> - Documentation:
http://docs.basex.org/
>>> - Snapshots:
http://files.basex.org/releases/latest/
>>> - Sources:
https://github.com/BaseXdb
>>>
>>> Enjoy the update!
>>>
>>> Christian
>>> BaseX Team
>>> _______________________________________________
>>> BaseX-Talk mailing list
>>> BaseX-Talk@mailman.uni-konstanz.de
>>>
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>> _______________________________________________
>> BaseX-Talk mailing list
>> BaseX-Talk@mailman.uni-konstanz.de
>>
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>>
> _______________________________________________
> BaseX-Talk mailing list
> BaseX-Talk@mailman.uni-konstanz.de
>
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk