[PATCH] Fix for EXE_SUFFIX being set for WSL having no effect
Andrew Luo
andrewluotechnologies at outlook.com
Sat Jan 19 03:59:59 UTC 2019
EXE_SUFFIX being .exe guarantees you that it is a Windows JVM under test (WSL currently), but I think EXE_SUFFIX could also be used for Cygwin as well (even though it is not used currently). Or perhaps another emulation layer, if we add support for yet another one in the future. But aside from that, I think from the perspective of clarity, it's not obviously (to someone that has no context) that EXE_SUFFIX == .exe => WSL and not Cygwin, because EXE_SUFFIX could be .exe on all Windows platforms. But if we set WSL_TARGET == windows, it's pretty obvious that that environment variable means WSL. Of course, the possibility of supporting another emulation layer is purely theoretical at this point, so if you have a strong preference, it doesn't matter that much to me.
But if I had a choice between the above (EXE_SUFFIX == .exe => WSL_TARGET = windows) and WSL_TARGET == windows => EXE_SUFFIX = .exe, I would prefer the latter, because EXE_SUFFIX doesn't explicitly guarantee you are on WSL.
Anyways, I want to hear any other thoughts on this...
Thanks,
-Andrew
-----Original Message-----
From: Jonathan Gibbons <jonathan.gibbons at oracle.com>
Sent: Friday, January 18, 2019 4:36 PM
To: Andrew Luo <andrewluotechnologies at outlook.com>; code-tools-dev at openjdk.java.net
Subject: Re: [PATCH] Fix for EXE_SUFFIX being set for WSL having no effect
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