[PATCH] Fix for EXE_SUFFIX being set for WSL having no effect

Jonathan Gibbons jonathan.gibbons at oracle.com
Sat Jan 19 00:36:16 UTC 2019



On 01/18/2019 03:56 PM, Jonathan Gibbons wrote:
>
> On a (somewhat related note), another thing I noticed is that some 
> scripts have logic such as:
>
> OS=`uname -s`;
> # Set classpath separator
> case "$OS" in
>           Windows* | CYGWIN* )
>     SEP=";"
>           ;;
>
>     * )
>     SEP=":"
> esac
>
> However, the classpath separator would depend on the platform of the 
> JVM under test (; for a Windows JVM under test, : for a Linux JVM 
> under test).  I could copy the above logic to detect the JVM under 
> test in the script, but this seems like overkill just to check whether 
> your target JVM is Windows or Linux.  So perhaps we could add another 
> environment variable, say WSL_TARGET, which would either be set to 
> "windows" for a Windows WSL target, or empty for Linux WSL 
> target/non-WSL.  That way the above logic could be rewritten:
>
> OS=`uname -s`;
> # Set classpath separator
> case "$OS" in
>           Windows* | CYGWIN* )
>     SEP=";"
>           ;;
>
>     * )
>     if [ "x${WSL_TARGET}" = "xwindows" ]; then
>         SEP=";"
>     else
>         SEP=":"
>     fi
> esac 

Just reading this fragment of your message, I think I'm beginning to see 
what you may be trying to do.  But WSL_TARGET seems like the wrong way 
to go.  If you need to use WSL_TARGET to fix up the "*" case, that means 
you executed "case" on the wrong value in the first place.

How about the following direction:

OS=`if [ "x${EXE_SUFFIX}" = "x.exe" ]; then echo "Windows_WSL" ; else 
uname -s; fi`;
# Set classpath separator
case "$OS" in
     Windows* | CYGWIN* )
           SEP=";"
           ;;

     * )
     SEP=":"
esac

or finesse it a bit:

SYSTEM=`if [ "x${EXE_SUFFIX}" = "x.exe" ]; then echo "WSL" ; else uname 
-s; fi`;
# Set classpath separator
case "$SYSTEM" in
     Windows* | CYGWIN* | WSL )
           SEP=";"
           ;;

     * )
     SEP=":"
esac

In other words, isn't EXE_SUFFIX already indirectly telling you that its 
a Windows JVM under test?

-- Jon


More information about the code-tools-dev mailing list