On 06/11/2012 04:17 PM, Dr. Yves Forkl (SRZ) wrote:
>>
>> A colleague of mine found this which should work fine on most Unix systems:
>>
>> ---
>> if [ -L "$0" ]; then
>> # Ugly but should work on most systems.
>> scriptFile=`ls -l "$0" | awk '{print $(NF)}'`
>> else
>> scriptFile="$0"
>> fi
>>
>> dist=`dirname "$scriptFile"`
>> ---
>
> This unfortunately doesn't work when the symlink's target is given as a
> relative path.
OK. Thanks for reporting the problem.
>
> After some research, I have worked out and tested the following solution [1]
> to deal with absolute or relative symlinks (or no link at all) to XXE's start
> script. Please check and confirm that this works on the Mac as well:
>
> --
> # Iterate down a (possible) chain of symlinks to locate the script
> # in order to determine the distribution directory
>
> scriptFile=$0
> cd `dirname $scriptFile`
> scriptFile=`basename $scriptFile`
>
> while [ -L "$scriptFile" ]
> do
> scriptFile=`ls -l "$scriptFile" | awk '{print $(NF)}'`
> cd `dirname $scriptFile`
> scriptFile=`basename $scriptFile`
> done
>
> # Compute the canonicalized name by finding the physical path
> # for the directory we're in.
> dist=`pwd -P`
> --
> This solution is heavily inspired by http://stackoverflow.com/a/1116890
Thanks for the above suggestion and for the pointer.
>
> As stated previously, it would be nice if in one of XXE's next releases, its
> start script was enhanced with
> the above code for reliably determining the distribution directory, even when
> the start script is accessed through a symlink.
We have finally decided to add this snippet to our shell scripts:
---
os=`uname -s`
if [ "$os" = "Linux" ]; then
scriptFile=`readlink -f "$0"`
else
scriptFile="$0"
fi
dist=`dirname "$scriptFile"`
---
Rationale:
* We officially support only Windows, Mac OS X and Linux. We do not
officially support any other Unix-like OS (e.g. BSD, Solaris).
* Mac OS X users are not supposed to use the xxe shell script. They are
supposed to double-click on the icon of XMLEditor.app.
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support