[ https://issues.apache.org/jira/browse/DERBY-2136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15000568#comment-15000568 ]
Ilguiz Latypov commented on DERBY-2136: --------------------------------------- Should this be re-opened for the case of the shell script startNetworkServer executed in Cygwin? The intent of the eval clause appears to parse a whitespace-separated value DERBY_OPTS into multiple arguments. But this has a side effect of interpreting the backslash, converting "c:\databases" to "c:databases". {code:none} latypil@MLIW3FZ8G12 /cygdrive/c/db-derby-10.11.1.1-bin/bin $ DERBY_OPTS='-Dderby.system.home=c:\databases' bash -x startNetworkServer [..] + derby_exec_command='exec "/cygdrive/c/ProgramData/Oracle/Java/javapath/java" -Dderby.system.home=c:\databases -classpath "C:/db-derby-10.11.1.1-bin/lib/derby.jar;C:/db-derby-10.11.1.1-bin/lib/derbynet.jar;C:/db-derby-10.11.1.1-bin/lib/derbytools.jar;C:/db-derby-10.11.1.1-bin/lib/derbyclient.jar" org.apache.derby.drda.NetworkServerControl start ' + eval exec '"/cygdrive/c/ProgramData/Oracle/Java/javapath/java"' '-Dderby.system.home=c:\databases' -classpath '"C:/db-derby-10.11.1.1-bin/lib/derby.jar;C:/db-derby-10.11.1.1-bin/lib/derbynet.jar;C:/db-derby-10.11.1.1-bin/lib/derbytools.jar;C:/db-derby-10.11.1.1-bin/lib/derbyclient.jar"' org.apache.derby.drda.NetworkServerControl start ++ exec /cygdrive/c/ProgramData/Oracle/Java/javapath/java -Dderby.system.home=c:databases -classpath 'C:/db-derby-10.11.1.1-bin/lib/derby.jar;C:/db-derby-10.11.1.1-bin/lib/derbynet.jar;C:/db-derby-10.11.1.1-bin/lib/derbytools.jar;C:/db-derby-10.11.1.1-bin/lib/derbyclient.jar' org.apache.derby.drda.NetworkServerControl start Wed Nov 11 10:33:24 EST 2015 : Security manager installed using the Basic server security policy. Wed Nov 11 10:33:25 EST 2015 : Apache Derby Network Server - 10.11.1.1 - (1616546) started and ready to accept connections on port 1527 {code} The following patch works for me. {code:none} --- startNetworkServer.orig 2015-08-19 10:18:40.858650900 -0400 +++ startNetworkServer 2015-11-11 10:56:03.271674100 -0500 @@ -137,54 +137,18 @@ CYGHOME=`cygpath --$format "$HOME"` fi -# add a second backslash to variables terminated by a backslash under cygwin -if $cygwin; then - case "$DERBY_HOME" in - *\\ ) - DERBY_HOME="$DERBY_HOME\\" - ;; - esac - case "$CYGHOME" in - *\\ ) - CYGHOME="$CYGHOME\\" - ;; - esac - case "$LOCALCLASSPATH" in - *\\ ) - LOCALCLASSPATH="$LOCALCLASSPATH\\" - ;; - esac - case "$CLASSPATH" in - *\\ ) - CLASSPATH="$CLASSPATH\\" - ;; - esac -fi - # Readjust classpath for MKS # expr match if [ \( "`expr $SHELL : '.*sh.exe$'`" -gt 0 \) -a \( "$cygwin" = "false" \) ]; then LOCALCLASSPATH=`echo $LOCALCLASSPATH | sed -E 's/([\d\w]*):([\d\w]*)/\1;\2/g '` fi -#!/bin/sh - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -derby_exec_command="exec \"$JAVACMD\" $DERBY_OPTS -classpath \"$LOCALCLASSPATH\" org.apache.derby.drda.NetworkServerControl start $@" -eval $derby_exec_command +# Unlike Bash variable assignments, double quotes in the exec line preserve the +# content from word expansion. We keep JAVACMD, LOCALCLASSPATH as single +# words. We expand DERBY_OPTS into possibly multiple words. We could expand +# DERBY_OPTS beforehand with derby_opts_array=($DERBY_OPTS) and then let shell +# expand the array notation "${derby_opts_array[@]}" into words. The "$@" +# construct expands this script's arguments into multiple words similarly to +# the array notation "${var[@]}". +exec "$JAVACMD" $DERBY_OPTS -classpath "$LOCALCLASSPATH" org.apache.derby.drda.NetworkServerControl start "$@" {code} The trace of the script shows preserved back-slashes, {code:none} + exec /cygdrive/c/ProgramData/Oracle/Java/javapath/java '-Dderby.system.home=c:\databases' -classpath 'C:/db-derby-10.11.1.1-bin/lib/derby.jar;C:/db-derby-10.11.1.1-bin/lib/derbynet.jar;C:/db-derby-10.11.1.1-bin/lib/derbytools.jar;C:/db-derby-10.11.1.1-bin/lib/derbyclient.jar' org.apache.derby.drda.NetworkServerControl start Wed Nov 11 10:58:11 EST 2015 : Security manager installed using the Basic server security policy. Wed Nov 11 10:58:11 EST 2015 : Apache Derby Network Server - 10.11.1.1 - (1616546) started and ready to accept connections on port 1527 {code} > Can't set system directory with derby.system.home for Network Server > -------------------------------------------------------------------- > > Key: DERBY-2136 > URL: https://issues.apache.org/jira/browse/DERBY-2136 > Project: Derby > Issue Type: Bug > Components: Documentation, Network Server > Reporter: Frederik > Priority: Minor > > I'm a total newcomer to Derby. Decided to play with it today after reading > http://www.regdeveloper.co.uk/2006/11/08/java_database_derby > I want to use the Network Server deployment mode. For determining the System > Directory (which holds properties file and the database directories, etc), I > understood from docs (e.g. > http://db.apache.org/derby/docs/10.2/devguide/cdevdvlp27610.html) that I > should set derby.system.home. > I tried (using the newer scripts in $DERBY_HOME/bin) > export DERBY_OPTS=-Dderby.system.home=/data/derby > startNetworkServer > but that failed to set the system directory properly (as witnessed by > "NetworkServerControl sysinfo"). It was using current directory when starting > derby. > I finally discovered that it works if I do > export DERBY_OPTS=-Duser.dir=/data/derby > startNetworkServer > That seems to be either a bug or a docbug to me. > (Almost all docs are using the scripts in > $DERBY_HOME/frameworks/NetworkServer/bin instead of the newer ones in ./bin ; > except for http://db.apache.org/derby/docs/10.2/getstart/ and the mention in > 10.2 release notes) -- This message was sent by Atlassian JIRA (v6.3.4#6332)