BaseX 7.0.1: Release early, release often..

Sunday, 23 October 2011 · 20 messages · last reply 10 Nov 2011
CG
Christian Grün23 Oct 2011 21:48 #
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
RJ
Ralf Jung24 Oct 2011 20:06 #
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
Quoted text · Christian Grün · 39 lines
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 at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
CG
Christian Grün25 Oct 2011 14:44 #
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
Quoted text · Ralf Jung · 77 lines
On Mon, Oct 24, 2011 at 8:06 PM, Ralf Jung <ralfjung-e at 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 at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
JE
Jens Erat25 Oct 2011 15:53 #
Hi Christian and Ralf, 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.
Quoted text · Christian Grün · 20 lines
> #!/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 at jenserat.de [jabber]: xmpp:jabber at jenserat.de [web]: http://www.jenserat.de PGP: 350E D9B6 9ADC 2DED F5F2 8549 CBC2 613C D745 722B
Quoted text · Christian Grün · 90 lines
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 at 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 at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
MS
Michael Seiferlein reply to Christian Grün, 25 Oct 2011, 14:4425 Oct 2011 15:53 #
Hey there, seems to work fine. Running OSX things are a little different anyway in case you installed BaseX from the downloadable disk image to /Applications/ you have to use the startup scripts that come with BaseX.app anyway. So I guess most OSX won't be affected by this change. I had a quick look at the actual issue and came up with [problem 1, solution 2]. We could maybe change the OSX scripts to call readlink (without -e) (in case calling it with -e failed) to have the actual startscripts reside inside BaseX.app I'll think about this, for now the solutiono looks fine. Kind regards Michael [1] https://github.com/diaspora/diaspora/issues/2020 [2] http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
Quoted text · Christian Grün · 4 lines
Am 25.10.2011 um 14:44 schrieb Christian Grün: > 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?
RJ
Ralf Jungin reply to Jens Erat, 25 Oct 2011, 15:5325 Oct 2011 15:59 #
Hi,
Quoted text · Jens Erat · 9 lines
> 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.
That will not work, how can the start scripts find the BaseX folder to source the path-resolution script? The whole code needs to be copied into each start script. Kind regards, Ralf
RJ
Ralf Jungin reply to Michael Seiferle, 25 Oct 2011, 15:531 Nov 2011 14:31 #
Hi, any news on this? It seems to work on Mac, and if you are willing to significantly bloat the startup scripts with the shell-equivalent of "readlink -e", you'd even get symlink support for Mac. The much shorter alternative I previously suggested doesn't break anything on Mac either. Kind regards, Ralf
Quoted text · Michael Seiferle · 27 lines
> seems to work fine. > Running OSX things are a little different anyway in case you installed > BaseX from the downloadable disk image to /Applications/ you have to use > the startup scripts that come with BaseX.app anyway. > > So I guess most OSX won't be affected by this change. > I had a quick look at the actual issue and came up with [problem 1, > solution 2]. > > We could maybe change the OSX scripts to call readlink (without -e) (in > case calling it with -e failed) to have the actual startscripts reside > inside BaseX.app > > I'll think about this, for now the solutiono looks fine. > > Kind regards > Michael > > [1] https://github.com/diaspora/diaspora/issues/2020 > [2] > http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-g > nus-readlink-f-on-a-mac > > Am 25.10.2011 um 14:44 schrieb Christian Grün: > > 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?
CG
Christian Grün2 Nov 2011 02:02 #
Ralf, sorry for delaying your request. I'll update the scripts this week. I'd prefer to have all redundant information in a single script anyway (at least for Linux/Max), so I might do some more rewritings. Best, Christian
Quoted text · Ralf Jung · 40 lines
On Tue, Nov 1, 2011 at 2:31 PM, Ralf Jung <ralfjung-e at gmx.de> wrote: > Hi, > > any news on this? It seems to work on Mac, and if you are willing to > significantly bloat the startup scripts with the shell-equivalent of "readlink > -e", you'd even get symlink support for Mac. The much shorter alternative I > previously suggested doesn't break anything on Mac either. > > Kind regards, > Ralf > > >> seems to work fine. >> Running OSX things are a little different anyway in case you installed >> BaseX from the downloadable disk image to /Applications/ you have to use >> the startup scripts that come with BaseX.app anyway. >> >> So I guess most OSX won't be affected by this change. >> I had a quick look at the actual issue and came up with [problem 1, >> solution 2]. >> >> We could maybe change the OSX scripts to call readlink (without -e) (in >> case calling it with -e failed) to have the actual startscripts reside >> inside BaseX.app >> >> I'll think about this, for now the solutiono looks fine. >> >> Kind regards >> Michael >> >> [1] https://github.com/diaspora/diaspora/issues/2020 >> [2] >> http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-g >> nus-readlink-f-on-a-mac >> >> Am 25.10.2011 um 14:44 schrieb Christian Grün: >> > 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? >
CG
Christian Grünin reply to Jens Erat, 25 Oct 2011, 15:533 Nov 2011 22:42 #
Hi Jens, hi Ralf,
Quoted text · Jens Erat · 1 line
> 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.
I'm feeling clumsy.. How will the script file be found by the main script if the absolute path has not been evaluated yet? Christian
Quoted text · Jens Erat · 148 lines
On Tue, Oct 25, 2011 at 3:53 PM, Jens Erat <jens.erat at uni-konstanz.de> wrote: > Hi Christian and Ralf, > > 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…) > > >> #!/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 > > > Kind regards, > Jens > > [1]:http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac/1116890#1116890 > > -- > Jens Erat > > [phone]: tel:+49-151-56961126 > [mail]: mailto:email at jenserat.de > [jabber]: xmpp:jabber at 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 at 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 at mailman.uni-konstanz.de >>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > -----BEGIN PGP SIGNATURE----- > > iQEcBAEBAgAGBQJOpr9cAAoJENqoVWI6Xmj3ToEIAK2IVsRobanZSfPB1qpxoLai > 0TY0DUOqz2IdVrsh/VlMSs/UT12cc4WbghEMKkBuQBrnOXi7MoHKc4lVzKIHWasb > +TH2Xg9sUY76xeZ2Z5ouhAJcAMULgp00pp9FHGEAqCXxLvwPNMLfNWunpP2i8HN/ > 6ITFLxci3bDC45x59R/aTbeqOeNO38spJKpnAg4cSOj4qyK7k9TH/kqz+B007VO/ > H2LGQI+9uEKV7edhBozrzJGl+LDZDgubgPaylRdeSc6jA4fn+YrDWlE2DagOwWqM > 5exsTL1Wv77XvrdxZvItrQULOXyuUrOb8oEmI1DM1ETqMA4wWjWg3PWYsv/J0ko= > =GIId > -----END PGP SIGNATURE----- > >
MS
Michael Seiferle4 Nov 2011 09:25 #
Quoted text · Christian Grün · 7 lines
Am 03.11.2011 um 22:42 schrieb Christian Grün: > Hi Jens, hi Ralf, > >> 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. > > I'm feeling clumsy.. How will the script file be found by the main > script if the absolute path has not been evaluated yet?
I guess the readlink mimic script should be residing inside $PATH anyway?
But I'd rather not bloat $PATH with yet another script and instead put that logic in every script that needs it, not too elegant, I admit.
Michael
RJ
Ralf Jungin reply to Christian Grün, 3 Nov 2011, 22:424 Nov 2011 16:48 #
Hi Christian, that's what I already replied to Jens and the list - naturally, any script that finds the script path must be emdedded into all startup scripts. Which for this script means that it has to be executed in a subshell since it changes the pwd... there was some shell syntax to do that, but I do not remember it currently. Kind regards, Ralf
Quoted text · Christian Grün · 164 lines
On Thursday 03 November 2011 22:42:34 Christian Grün wrote: > Hi Jens, hi Ralf, > > > 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. > > I'm feeling clumsy.. How will the script file be found by the main > script if the absolute path has not been evaluated yet? > > Christian > ___________________________ > > On Tue, Oct 25, 2011 at 3:53 PM, Jens Erat <jens.erat at uni-konstanz.de> wrote: > > Hi Christian and Ralf, > > > > 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…) > > > >> #!/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 > > > > Kind regards, > > Jens > > > > [1]:http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior > > -of-gnus-readlink-f-on-a-mac/1116890#1116890 > > > > -- > > Jens Erat > > > > [phone]: tel:+49-151-56961126 > > [mail]: mailto:email at jenserat.de > > [jabber]: xmpp:jabber at 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 at 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 at mailman.uni-konstanz.de > >>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >>> > >>> _______________________________________________ > >>> BaseX-Talk mailing list > >>> BaseX-Talk at mailman.uni-konstanz.de > >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >> > >> _______________________________________________ > >> BaseX-Talk mailing list > >> BaseX-Talk at mailman.uni-konstanz.de > >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > -----BEGIN PGP SIGNATURE----- > > > > iQEcBAEBAgAGBQJOpr9cAAoJENqoVWI6Xmj3ToEIAK2IVsRobanZSfPB1qpxoLai > > 0TY0DUOqz2IdVrsh/VlMSs/UT12cc4WbghEMKkBuQBrnOXi7MoHKc4lVzKIHWasb > > +TH2Xg9sUY76xeZ2Z5ouhAJcAMULgp00pp9FHGEAqCXxLvwPNMLfNWunpP2i8HN/ > > 6ITFLxci3bDC45x59R/aTbeqOeNO38spJKpnAg4cSOj4qyK7k9TH/kqz+B007VO/ > > H2LGQI+9uEKV7edhBozrzJGl+LDZDgubgPaylRdeSc6jA4fn+YrDWlE2DagOwWqM > > 5exsTL1Wv77XvrdxZvItrQULOXyuUrOb8oEmI1DM1ETqMA4wWjWg3PWYsv/J0ko= > > =GIId > > -----END PGP SIGNATURE-----
DP
Dimitar Popov4 Nov 2011 23:15 #
Quoted text · 16:48:10 · 2 lines
Am Freitag, 4. November 2011, 16:48:10 schrieb Ralf Jung: > there was some shell syntax to do that, but I do not remember it currently.
Again the holy StackOverflow with the help of it's helper St. Google: http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what- directory-its-stored-in Cheers, Dimitar
RJ
Ralf Jung4 Nov 2011 23:31 #
Unfortunately all solutions proposed there have problems with relative symlinks, which readlink does not resolve to absolute paths... (I have a symlink in ~/bin called basexhttp pointing to "basex/bin/basexhttp", but it tries to resolve the relative path from the directory I am in, instead of ~/bin) The shortest one I could come up with that works for me and does not use readlink -e is based on <http://stackoverflow.com/questions/1055671/how-can-i- get-the-behavior-of-gnus-readlink-f-on-a-mac> # find Path to this script pushd . > /dev/null SCRIPT_FILE="${BASH_SOURCE[0]}" cd "$(dirname "$SCRIPT_FILE")" SCRIPT_FILE="$(basename "$SCRIPT_FILE")" # we need to get rid of the path part since we cd'ed # Iterate down a (possible) chain of symlinks while [ -L "$SCRIPT_FILE" ] do SCRIPT_FILE="$(readlink "$SCRIPT_FILE")" cd "$(dirname "$SCRIPT_FILE")" SCRIPT_FILE="$(basename "$SCRIPT_FILE")" done # now we are in the directory we are looking for SCRIPT_DIR="$(pwd -P)" popd > /dev/null Kind regards, Ralf
Quoted text · 16:48:10 · 12 lines
On Friday 04 November 2011 23:15:44 Dimitar Popov wrote: > Am Freitag, 4. November 2011, 16:48:10 schrieb Ralf Jung: > > there was some shell syntax to do that, but I do not remember it > > currently. > > Again the holy StackOverflow with the help of it's helper St. Google: > > http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what- > directory-its-stored-in > > Cheers, > Dimitar
DP
Dimitar Popov4 Nov 2011 23:41 #
Quoted text · 23:31:27 · 28 lines
Am Freitag, 4. November 2011, 23:31:27 schrieb Ralf Jung: > Unfortunately all solutions proposed there have problems with relative > symlinks, which readlink does not resolve to absolute paths... > (I have a symlink in ~/bin called basexhttp pointing to > "basex/bin/basexhttp", but it tries to resolve the relative path from the > directory I am in, instead of ~/bin) > > The shortest one I could come up with that works for me and does not use > readlink -e is based on > <http://stackoverflow.com/questions/1055671/how-can-i- > get-the-behavior-of-gnus-readlink-f-on-a-mac> > > # find Path to this script > pushd . > /dev/null > SCRIPT_FILE="${BASH_SOURCE[0]}" > cd "$(dirname "$SCRIPT_FILE")" > SCRIPT_FILE="$(basename "$SCRIPT_FILE")" # we need to get rid of the path > part since we cd'ed > # Iterate down a (possible) chain of symlinks > while [ -L "$SCRIPT_FILE" ] > do > SCRIPT_FILE="$(readlink "$SCRIPT_FILE")" > cd "$(dirname "$SCRIPT_FILE")" > SCRIPT_FILE="$(basename "$SCRIPT_FILE")" > done > # now we are in the directory we are looking for > SCRIPT_DIR="$(pwd -P)" > popd > /dev/null
What's wrong with simply using
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
PWD="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
? It works on my computer, but I'm not Bash profi, so I might be missing something... Greetings, Dimitar
DP
Dimitar Popov4 Nov 2011 23:44 #
Quoted text · 23:31:27 · 42 lines
Am Freitag, 4. November 2011, 23:41:31 schrieb Dimitar Popov: > Am Freitag, 4. November 2011, 23:31:27 schrieb Ralf Jung: > > Unfortunately all solutions proposed there have problems with relative > > symlinks, which readlink does not resolve to absolute paths... > > (I have a symlink in ~/bin called basexhttp pointing to > > "basex/bin/basexhttp", but it tries to resolve the relative path from > > the > > directory I am in, instead of ~/bin) > > > > The shortest one I could come up with that works for me and does not use > > readlink -e is based on > > <http://stackoverflow.com/questions/1055671/how-can-i- > > get-the-behavior-of-gnus-readlink-f-on-a-mac> > > > > # find Path to this script > > pushd . > /dev/null > > SCRIPT_FILE="${BASH_SOURCE[0]}" > > cd "$(dirname "$SCRIPT_FILE")" > > SCRIPT_FILE="$(basename "$SCRIPT_FILE")" # we need to get rid of the > > path > > part since we cd'ed > > # Iterate down a (possible) chain of symlinks > > while [ -L "$SCRIPT_FILE" ] > > do > > > > SCRIPT_FILE="$(readlink "$SCRIPT_FILE")" > > cd "$(dirname "$SCRIPT_FILE")" > > SCRIPT_FILE="$(basename "$SCRIPT_FILE")" > > > > done > > # now we are in the directory we are looking for > > SCRIPT_DIR="$(pwd -P)" > > popd > /dev/null > > What's wrong with simply using > > SOURCE="${BASH_SOURCE[0]}" > while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done > PWD="$( cd -P "$( dirname "$SOURCE" )" && pwd )" > > ? It works on my computer, but I'm not Bash profi, so I might be missing > something...
Ah, ok... I understand... "relative" is the keyword ;) It's getting late... Greetings, Dimitar
DP
Dimitar Popovin reply to Ralf Jung, 4 Nov 2011, 23:316 Nov 2011 21:22 #
Hi Ralf, I modified your script a little, and came with the following shorter solution:
FILE="${BASH_SOURCE[0]}"
while [ -h "$FILE" ] ; do
  SOURCE="$(readlink "$FILE")"
  FILE="$(dirname "$FILE")/$(dirname "$SOURCE")/$(basename "$SOURCE")"
done
BASEX_DIR="$( cd -P "$(dirname $FILE)" && pwd )"
Could you give it a try and tell me if you see any problems with it? Many thanks in advance! Dimitar
Quoted text · 23:31:27 · 44 lines
Am Freitag, 4. November 2011, 23:31:27 schrieb Ralf Jung: > Unfortunately all solutions proposed there have problems with relative > symlinks, which readlink does not resolve to absolute paths... > (I have a symlink in ~/bin called basexhttp pointing to > "basex/bin/basexhttp", but it tries to resolve the relative path from the > directory I am in, instead of ~/bin) > > The shortest one I could come up with that works for me and does not use > readlink -e is based on > <http://stackoverflow.com/questions/1055671/how-can-i- > get-the-behavior-of-gnus-readlink-f-on-a-mac> > > # find Path to this script > pushd . > /dev/null > SCRIPT_FILE="${BASH_SOURCE[0]}" > cd "$(dirname "$SCRIPT_FILE")" > SCRIPT_FILE="$(basename "$SCRIPT_FILE")" # we need to get rid of the path > part since we cd'ed > # Iterate down a (possible) chain of symlinks > while [ -L "$SCRIPT_FILE" ] > do > SCRIPT_FILE="$(readlink "$SCRIPT_FILE")" > cd "$(dirname "$SCRIPT_FILE")" > SCRIPT_FILE="$(basename "$SCRIPT_FILE")" > done > # now we are in the directory we are looking for > SCRIPT_DIR="$(pwd -P)" > popd > /dev/null > > Kind regards, > Ralf > > On Friday 04 November 2011 23:15:44 Dimitar Popov wrote: > > Am Freitag, 4. November 2011, 16:48:10 schrieb Ralf Jung: > > > there was some shell syntax to do that, but I do not remember it > > > currently. > > > > Again the holy StackOverflow with the help of it's helper St. Google: > > > > http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what- > > directory-its-stored-in > > > > Cheers, > > Dimitar
DP
Dimitar Popov6 Nov 2011 21:25 #
Quoted text · 21:22:57 · 18 lines
Am Sonntag, 6. November 2011, 21:22:57 schrieb Dimitar Popov: > Hi Ralf, > > I modified your script a little, and came with the following shorter > solution: > > FILE="${BASH_SOURCE[0]}" > while [ -h "$FILE" ] ; do > SOURCE="$(readlink "$FILE")" > FILE="$(dirname "$FILE")/$(dirname "$SOURCE")/$(basename "$SOURCE")" > done > BASEX_DIR="$( cd -P "$(dirname $FILE)" && pwd )" > > Could you give it a try and tell me if you see any problems with it? > > Many thanks in advance! > > Dimitar
Forget it... it doesn't work correctly. Dimitar
RJ
Ralf Jungin reply to Dimitar Popov, 6 Nov 2011, 21:226 Nov 2011 21:46 #
(resent with correct recipien ts) Hi, this will break if the link is absolute, since it will still prepend the $(dirname "$FILE") to the value we got from readlink. So if I call /home/r/bin/basexhttp, which is a link to /home/r/bin/basex/bin/basexhttp, it will set FILE to /home/r/bin//home/r/bin/basex/bin/basexhttp. Also, I wonder why you are splitting $SOURCE into basename and dirname, just to concat it again? Kind regards, Ralf
Quoted text · Dimitar Popov · 65 lines
On Sunday 06 November 2011 21:22:57 you wrote: > Hi Ralf, > > I modified your script a little, and came with the following shorter > solution: > > FILE="${BASH_SOURCE[0]}" > while [ -h "$FILE" ] ; do > SOURCE="$(readlink "$FILE")" > FILE="$(dirname "$FILE")/$(dirname "$SOURCE")/$(basename "$SOURCE")" > done > BASEX_DIR="$( cd -P "$(dirname $FILE)" && pwd )" > > Could you give it a try and tell me if you see any problems with it? > > Many thanks in advance! > > Dimitar > > Am Freitag, 4. November 2011, 23:31:27 schrieb Ralf Jung: > > Unfortunately all solutions proposed there have problems with relative > > symlinks, which readlink does not resolve to absolute paths... > > (I have a symlink in ~/bin called basexhttp pointing to > > "basex/bin/basexhttp", but it tries to resolve the relative path from the > > directory I am in, instead of ~/bin) > > > > The shortest one I could come up with that works for me and does not use > > readlink -e is based on > > <http://stackoverflow.com/questions/1055671/how-can-i- > > get-the-behavior-of-gnus-readlink-f-on-a-mac> > > > > # find Path to this script > > pushd . > /dev/null > > SCRIPT_FILE="${BASH_SOURCE[0]}" > > cd "$(dirname "$SCRIPT_FILE")" > > SCRIPT_FILE="$(basename "$SCRIPT_FILE")" # we need to get rid of the path > > part since we cd'ed > > # Iterate down a (possible) chain of symlinks > > while [ -L "$SCRIPT_FILE" ] > > do > > > > SCRIPT_FILE="$(readlink "$SCRIPT_FILE")" > > cd "$(dirname "$SCRIPT_FILE")" > > SCRIPT_FILE="$(basename "$SCRIPT_FILE")" > > > > done > > # now we are in the directory we are looking for > > SCRIPT_DIR="$(pwd -P)" > > popd > /dev/null > > > > Kind regards, > > Ralf > > > > On Friday 04 November 2011 23:15:44 Dimitar Popov wrote: > > > Am Freitag, 4. November 2011, 16:48:10 schrieb Ralf Jung: > > > > there was some shell syntax to do that, but I do not remember it > > > > currently. > > > > > > Again the holy StackOverflow with the help of it's helper St. Google: > > > > > > http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what- > > > directory-its-stored-in > > > > > > Cheers, > > > Dimitar
RJ
Ralf Jung7 Nov 2011 22:41 #
Hi,
Quoted text · Ralf Jung · 2 lines
> Yep, that was not necessary. Here is a version, which I hope works > correctly:
That's looking great, I just added a missing " " around the last $FILE.
FILE="${BASH_SOURCE[0]}"
while [ -h "$FILE" ] ; do
  SOURCE="$(readlink "$FILE")"
  FILE="$( cd -P "$(dirname "$FILE")" && \
           cd -P "$(dirname "$SOURCE")" && pwd )/$(basename "$SOURCE")"
done
BASEX_DIR="$( cd -P "$(dirname "$FILE")" && pwd )"
Of course, in the remainder of the script, $PWD has to be replaced by BASEX_DIR... or, to make things slightly more readable, BASEX_DIR could be the actual dir with the main jar, not the bin dir. While I was at it, I also fixed the "list all jars in lib/" part to work properly if the path basex lives in contains a ' ' (which would previously have been replaced by a ':'). You can find the result attached. It works here, but should be tested on some different setups :D Kind regards, Ralf
RJ
Ralf Jung10 Nov 2011 21:37 #
Hi again, I saw you committed this - thanks a lot :) Kind regards, Ralf
Quoted text · 21:26:03 · 27 lines
On Sunday 06 November 2011 22:23:03 Dimitar Popov wrote: > Am Sonntag, 6. November 2011, 21:26:03 schrieb Ralf Jung: > > Hi, > > > > this will break if the link is absolute, since it will still prepend the > > $(dirname "$FILE") to the value we got from readlink. So if I call > > /home/r/bin/basexhttp, which is a link to > > /home/r/bin/basex/bin/basexhttp, it will set FILE to > > /home/r/bin//home/r/bin/basex/bin/basexhttp. > > Yes, I saw that, but a second after I sent the email :) > > > Also, I wonder why you are splitting $SOURCE into basename and dirname, > > just to concat it again? > > Yep, that was not necessary. Here is a version, which I hope works > correctly: > > FILE="${BASH_SOURCE[0]}" > while [ -h "$FILE" ] ; do > SOURCE="$(readlink "$FILE")" > FILE="$( cd -P "$(dirname "$FILE")" && \ > cd -P "$(dirname "$SOURCE")" && pwd )/$(basename "$SOURCE")" > done > BASEX_DIR="$( cd -P "$(dirname $FILE)" && pwd )" > > Dimitar

⚡Generated with XQuery