Derby
  1. Derby
  2. DERBY-2897

setEmbeddedCP.bat script fails (mangles DERBY_HOME variable) when the path in DERBY_HOME contains a dot

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 10.3.1.4
    • Fix Version/s: None
    • Component/s: Demos/Scripts
    • Labels:
      None
    • Environment:
      Windows 2000

      Description

      Following command sequence shows the problem when DERBY_HOME has a dot in a folder name (e.g. 10.3RC1) - note the string "4DBA~1" in the middle of 10.3RC1.

      -> bin\setEmbeddedCP.bat
      DERBY_HOME or DERBY_INSTALL not set. Set one of these variables
      to the location of your Derby installation.

      -> set DERBY_HOME=C:\CldScpInstalls\Test\10.3RC1

      -> bin\setEmbeddedCP.bat

      -> SET DERBY_HOME=C:\CLDSCP~1\Test\104DBA~1.3RC1

      -> set CLASSPATH=C:\CLDSCP~1\Test\104DBA~1.3RC1\lib\derby.jar;C:\CLDSCP~1\Test\104DBA~1.3RC1\lib\derbytools.jar;

        Activity

        Hide
        John H. Embretsen added a comment - - edited

        After some investigation, I have come to the conclusion that this issue is most likely invalid, for the following reasons:

        • The "mangling" is not caused by the dot itself, but it is caused by having one or more "non-8.3 compliant" directory names in DERBY_HOME. "8.3" is a common name for the old MS-DOS type of file names with a maximum of 8 character file name plus a 3 character extension (e.g. "PROGRAMS.TXT"). The directory name "10.3RC1" has 4 characters in the extension, so it is treated as a "Long File Name" (LFN), not an 8.3 file name. The "s" in the for loop in the script causes the directory name to be converted from LFN to 8.3 (see below).
        • The script does not actually fail, because the "mangled" versions of DERBY_HOME and CLASSPATH are valid file system paths in Windows. E.g. running "java org.apache.derby.tools.sysinfo" after running the script should still work.

        DERBY_HOME is modified in the script by the following line:

        @FOR %%X in ("%DERBY_HOME%") DO SET DERBY_HOME=%%~sX

        Where X is a variable reflecting the value of %DERBY_HOME%, and
        ~ expands X removing any surrounding quotes (")
        s means that the "expanded path contains short names only"

        (type FOR /? at a Windows command prompt for details)

        Having said that, I don't really understand why the "s" (for converting to 8.3 names) is used, or why the for loop is used at all. All we have to do is to use the value of DERBY_HOME for setting the CLASSPATH variable...

        One possible explanation is that this would perhaps make the script work with paths with spaces in them as well, but I have not been able to find the actual reasoning behind this (it has been like this since the scripts were donated to Apache). I'm still a bit confused when it comes to handling spaces in paths in batch files and environment variables on Windows, so I don't have a better suggestion at the moment.

        Show
        John H. Embretsen added a comment - - edited After some investigation, I have come to the conclusion that this issue is most likely invalid, for the following reasons: The "mangling" is not caused by the dot itself, but it is caused by having one or more "non-8.3 compliant" directory names in DERBY_HOME. "8.3" is a common name for the old MS-DOS type of file names with a maximum of 8 character file name plus a 3 character extension (e.g. "PROGRAMS.TXT"). The directory name "10.3RC1" has 4 characters in the extension, so it is treated as a "Long File Name" (LFN), not an 8.3 file name. The "s" in the for loop in the script causes the directory name to be converted from LFN to 8.3 (see below). The script does not actually fail, because the "mangled" versions of DERBY_HOME and CLASSPATH are valid file system paths in Windows. E.g. running "java org.apache.derby.tools.sysinfo" after running the script should still work. DERBY_HOME is modified in the script by the following line: @FOR %%X in ("%DERBY_HOME%") DO SET DERBY_HOME=%%~sX Where X is a variable reflecting the value of %DERBY_HOME%, and ~ expands X removing any surrounding quotes (") s means that the "expanded path contains short names only" (type FOR /? at a Windows command prompt for details) Having said that, I don't really understand why the "s" (for converting to 8.3 names) is used, or why the for loop is used at all. All we have to do is to use the value of DERBY_HOME for setting the CLASSPATH variable... One possible explanation is that this would perhaps make the script work with paths with spaces in them as well, but I have not been able to find the actual reasoning behind this (it has been like this since the scripts were donated to Apache). I'm still a bit confused when it comes to handling spaces in paths in batch files and environment variables on Windows, so I don't have a better suggestion at the moment.
        Hide
        Rick Hillegas added a comment -

        Closing this issue for the following reasons:

        1) The behavior seems to be expected.

        2) There has been no activity on this issue for a year and a half.

        Show
        Rick Hillegas added a comment - Closing this issue for the following reasons: 1) The behavior seems to be expected. 2) There has been no activity on this issue for a year and a half.

          People

          • Assignee:
            Unassigned
            Reporter:
            Stan Bradbury
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development