Hi,

h2.sh introduced at 1.3.163 works very fine except in the rare cases
below:
a. h2-1.3.*.jar is located on the current working directory and h2.sh
is not.
b. h2.sh is located on the directory whose name contains spaces, such
as '/opt/foo bar/h2.sh'
The former case breaks the compatibility to the older versions.
I  also found the one more rare case same as 'b.':
c. Web browser is located on the directory containing spaces, such as
  java org.h2.tools.Console -browser '/opt/web browser/browser' blah
blah...

cf. 
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_05_02

This is a patch which fixes a, b, c, removes a version number in it,
and is still very simple.

> diff -uaw h2.sh.orig h2.sh
--- h2.sh.orig  2012-02-03 12:01:12.000000000 +0900
+++ h2.sh       2012-02-22 14:29:49.000000000 +0900
@@ -1,11 +1,15 @@
 #!/bin/sh
-dir="$(dirname $0)"
-cp="$dir/h2-1.3.164.jar"
-if [ -n "$H2DRIVERS" ] ; then
-  cp="$cp:$H2DRIVERS"
+#PATH=/bin:/usr/bin:/usr/local/bin
+if [ -z "$H2DRIVERS" ]; then
+  dir=$(dirname "$0")
+  set +o noglob
+  H2DRIVERS=$(ls -1 "$dir"/h2-*.jar 2>/dev/null | sort -nr -t . |
head -1)
+  [ -z "$H2DRIVERS" ] && H2DRIVERS=$(ls -1 h2-*.jar 2>/dev/null |
sort -nr -t . | head -1)
 fi
-if [ -n "$CLASSPATH" ] ; then
-  cp="$cp:$CLASSPATH"
+if [ -n "$H2DRIVERS" -a -n "$CLASSPATH" ]; then
+  cp="$H2DRIVERS:$CLASSPATH"
+else
+  cp="$H2DRIVERS$CLASSPATH"
 fi
-java -cp "$cp" org.h2.tools.Console $@
-
+java -cp "$cp" org.h2.tools.Console "$@"
+# end of file.
-----

I hope this helps.
---
Fumiyuki Shimizu


On Dec 2 2011, 5:51 am, Thomas Mueller <[email protected]>
wrote:
> Hi,
>
> Thanks a lot! I'm not an expert inshellscripts, but unless somebody
> objects I will apply your patch.
>
> Regards,
> Thomas
>
>
>
> On Mon, Nov 28, 2011 at 4:19 PM, Daniel Serodio <[email protected]> wrote:
> > The current h2.shscriptonly works if it's ran from within the "bin/"
> > directory of the distribution (ie ./h2.sh). This patch makes it work
> > from any directory (ie /opt/h2/bin/h2.sh):
>
> > --- h2.sh       2011-11-28 13:14:20.000000000 -0200
> > +++ h2.sh.orig  2011-11-28 13:13:45.000000000 -0200
> > @@ -1,5 +1,7 @@
> >  #!/bin/sh
> > -cp=h2-1.3.162.jar
> > +dir="$(dirname $0)"
> > +cp="$dir/h2-1.3.162.jar"
> > +
> >  if [ -n "$H2DRIVERS" ] ; then
> >   cp="$cp:$H2DRIVERS"
> >  fi
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "H2 Database" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/h2-database?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to