Derby
  1. Derby
  2. DERBY-4283

setEmbeddedCP should not exit on error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.5.1.1
    • Fix Version/s: 10.5.3.2, 10.6.1.0
    • Component/s: Demos/Scripts
    • Labels:
      None
    • Environment:
      cygwin on windows (bash)
    • Urgency:
      Normal
    • Issue & fix info:
      Known fix, Newcomer, Repro attached, Workaround attached

      Description

      setEmbeddedCP should use 'return' instead of 'exit' if DERBY_HOME was not set.
      Because this script will be sourced from a shell, use of exit will terminate the calling shell.

        Issue Links

          Activity

          Hide
          Dag H. Wanvik added a comment -

          I am not sure this is a bug; if DERBY_HOME is not set, the CLASSPATH will not be set up correctly,
          and this will be silently ignored if a "return" is used. It is a precondition for using this script that DERBY_HOME has been set up.

          Cf. http://db.apache.org/derby/docs/dev/getstart/tgssetupenvironment.html and
          http://db.apache.org/derby/docs/dev/getstart/tgs26250.html

          Show
          Dag H. Wanvik added a comment - I am not sure this is a bug; if DERBY_HOME is not set, the CLASSPATH will not be set up correctly, and this will be silently ignored if a "return" is used. It is a precondition for using this script that DERBY_HOME has been set up. Cf. http://db.apache.org/derby/docs/dev/getstart/tgssetupenvironment.html and http://db.apache.org/derby/docs/dev/getstart/tgs26250.html
          Hide
          Dag H. Wanvik added a comment -

          I tried with "return 1" and it did set the status in the sourcing shell, so the condition could be checked,
          so I think the fix suggestion is good, thanks, Susumu.

          Triaged for 10.5.2, setting urgency to "normal", checking "newcomer", "known fix".

          Show
          Dag H. Wanvik added a comment - I tried with "return 1" and it did set the status in the sourcing shell, so the condition could be checked, so I think the fix suggestion is good, thanks, Susumu. Triaged for 10.5.2, setting urgency to "normal", checking "newcomer", "known fix".
          Hide
          Dag H. Wanvik added a comment -

          As a work-around, the calling shell could test if "DERBY_HOME" has been set before sourcing the
          setEmbeddedCP.

          Show
          Dag H. Wanvik added a comment - As a work-around, the calling shell could test if "DERBY_HOME" has been set before sourcing the setEmbeddedCP.
          Hide
          Dag H. Wanvik added a comment -

          Also setting "repro attached" and "workaround attached".

          Show
          Dag H. Wanvik added a comment - Also setting "repro attached" and "workaround attached".
          Hide
          Bryan Pendleton added a comment -

          Is there any controversy here? Seems like we should just make this change.

          Dag, do you see any reason I shouldn't go ahead and commit this change to the trunk?

          Show
          Bryan Pendleton added a comment - Is there any controversy here? Seems like we should just make this change. Dag, do you see any reason I shouldn't go ahead and commit this change to the trunk?
          Hide
          Dag H. Wanvik added a comment -

          +1
          The change is compatible with the doc text in
          http://db.apache.org/derby/docs/10.5/getstart/tgs26250.html:

          setEmbeddedCP
          Use the setEmbeddedCP script to set the classpath when the database engine is used in embedded mode.
          This script adds the derby.jar and derbytools.jar files to the classpath.

          Show
          Dag H. Wanvik added a comment - +1 The change is compatible with the doc text in http://db.apache.org/derby/docs/10.5/getstart/tgs26250.html: setEmbeddedCP Use the setEmbeddedCP script to set the classpath when the database engine is used in embedded mode. This script adds the derby.jar and derbytools.jar files to the classpath.
          Hide
          Bryan Pendleton added a comment -

          Thank you Susumu Ishizuka for the suggestion, and thanks Dag for the review and testing.

          The change seemed to work as expected in my Red Hat Linux environment as well
          (see below), so I committed it to the subversion trunk as revision 826263.

          -bash-2.05b$ ./bin/setEmbeddedCP
          Error: DERBY_HOME is not set. Please set the DERBY_HOME environment variable
          to the location of your Derby installation.
          ./bin/setEmbeddedCP: line 23: return: can only `return' from a function or sourced script
          -bash-2.05b$ echo $?
          0
          -bash-2.05b$ . ./bin/setEmbeddedCP
          Error: DERBY_HOME is not set. Please set the DERBY_HOME environment variable
          to the location of your Derby installation.
          -bash-2.05b$ echo $?
          1
          -bash-2.05b$ DERBY_HOME=/home/bpendleton/downloads/derby/db-derby-10.1.1.0-bin/lib . bin/setEmbeddedCP
          -bash-2.05b$ echo $?
          0
          -bash-2.05b$ echo $CLASSPATH
          /home/bpendleton/downloads/derby/db-derby-10.1.1.0-bin/lib/lib/derby.jar:/home/bpendleton/downloads/derby/db-derby-10.1.1.0-bin/lib/lib/derbytools.jar:

          Show
          Bryan Pendleton added a comment - Thank you Susumu Ishizuka for the suggestion, and thanks Dag for the review and testing. The change seemed to work as expected in my Red Hat Linux environment as well (see below), so I committed it to the subversion trunk as revision 826263. -bash-2.05b$ ./bin/setEmbeddedCP Error: DERBY_HOME is not set. Please set the DERBY_HOME environment variable to the location of your Derby installation. ./bin/setEmbeddedCP: line 23: return: can only `return' from a function or sourced script -bash-2.05b$ echo $? 0 -bash-2.05b$ . ./bin/setEmbeddedCP Error: DERBY_HOME is not set. Please set the DERBY_HOME environment variable to the location of your Derby installation. -bash-2.05b$ echo $? 1 -bash-2.05b$ DERBY_HOME=/home/bpendleton/downloads/derby/db-derby-10.1.1.0-bin/lib . bin/setEmbeddedCP -bash-2.05b$ echo $? 0 -bash-2.05b$ echo $CLASSPATH /home/bpendleton/downloads/derby/db-derby-10.1.1.0-bin/lib/lib/derby.jar:/home/bpendleton/downloads/derby/db-derby-10.1.1.0-bin/lib/lib/derbytools.jar:
          Hide
          Kathey Marsden added a comment -

          Reopen for backport.

          Show
          Kathey Marsden added a comment - Reopen for backport.
          Hide
          Mike Matrigali added a comment -

          temporarily assigning issue to myself while backporting to 10.5.

          Show
          Mike Matrigali added a comment - temporarily assigning issue to myself while backporting to 10.5.
          Hide
          Kathey Marsden added a comment -

          Assign to myself temporarily for backport

          Show
          Kathey Marsden added a comment - Assign to myself temporarily for backport
          Hide
          Kathey Marsden added a comment -

          Oops too early for this. I see Mike already picked this one up. Assigning back to Mike

          Show
          Kathey Marsden added a comment - Oops too early for this. I see Mike already picked this one up. Assigning back to Mike
          Hide
          Mike Matrigali added a comment -

          backported to 10.5. resetting original owner and resolving.

          Show
          Mike Matrigali added a comment - backported to 10.5. resetting original owner and resolving.
          Hide
          Knut Anders Hatlen added a comment -

          [bulk update] Close all resolved issues that haven't been updated for more than one year.

          Show
          Knut Anders Hatlen added a comment - [bulk update] Close all resolved issues that haven't been updated for more than one year.

            People

            • Assignee:
              Bryan Pendleton
              Reporter:
              Susumu Ishizuka
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development