Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --release param check in bootstrap.bat #205

Closed
wants to merge 1 commit into from
Closed

Fix --release param check in bootstrap.bat #205

wants to merge 1 commit into from

Conversation

mataha
Copy link
Contributor

@mataha mataha commented Sep 13, 2023

The following check will always fail silently due to batch echo always taking strings literally - including double quotes:

echo "public class JavacVersionCheck {}" >%CLASSDIR%\JavacVersionCheck.java
"%JAVAC%" --release 8 -d %CLASSDIR% %CLASSDIR%\JavacVersionCheck.java >nul 2>&1

With the following error message:

JavacVersionCheck.java:1: error: class, interface, or enum expected
"public class JavacVersionCheck {}"
^
1 error

Even with that fixed, the next statement will crash and burn on systems that do not have Command Extensions enabled (e.g. invoked with cmd /y):

IF %ERRORLEVEL% EQU 0 SET JAVAC_RELEASE_VERSION="--release 8"

With the following error message:

EQU was unexpected at this time.

In order to accommodate that, those checks have been corrected.

@jaikiran
Copy link
Member

Hello @mataha, what you propose here looks OK to me. However, I haven't been able to reproduce the issue that prompted this change. Is there some specific Windows version where this can be reproduced or how did you notice this issue?

The following check will always fail silently due to batch `echo` always
taking strings literally - including double quotes:

    echo "public class JavacVersionCheck {}" >%CLASSDIR%\JavacVersionCheck.java
    "%JAVAC%" --release 8 -d %CLASSDIR% %CLASSDIR%\JavacVersionCheck.java >nul 2>&1

With the following error message:

    JavacVersionCheck.java:1: error: class, interface, or enum expected
    "public class JavacVersionCheck {}"
    ^
    1 error

Even with that fixed, the next statement will crash and burn on systems
that do not have Command Extensions enabled (e.g. invoked with `cmd /y`):

    IF %ERRORLEVEL% EQU 0 SET JAVAC_RELEASE_VERSION="--release 8"

With the following error message:

    EQU was unexpected at this time.

In order to accommodate that, those checks have been corrected.

Signed-off-by: Mateusz Kazimierczuk <[email protected]>
@mataha
Copy link
Contributor Author

mataha commented Sep 16, 2023

Hello @mataha, what you propose here looks OK to me. However, I haven't been able to reproduce the issue that prompted this change. Is there some specific Windows version where this can be reproduced or how did you notice this issue?

Hello,

Try these minimal examples:

cmd /d /y /c "echo "public class JavacVersionCheck {}" >check.java && javac check.java"
cmd /d /y /c "if %ERRORLEVEL% equ 0 echo Success."

As for how I've noticed the issue: I wanted to analyze the bootstrapping code (having come here from Bootstrappable Builds); as I write a lot of Batch scripts as a result of my hobby, the quotes in echo struck me as a red flag immediately.

@mataha
Copy link
Contributor Author

mataha commented Sep 16, 2023

These, of course, can be run on all Windows versions.

@asfgit asfgit closed this in 5c89d9e Sep 17, 2023
@jaikiran
Copy link
Member

Thank you @mataha for those details. I have now merged this PR and added you (Mateusz Kazimierczuk) as a contributor to our contributors list.

@mataha mataha deleted the fix/bootstrap/release-param branch September 17, 2023 15:33
@mataha
Copy link
Contributor Author

mataha commented Sep 17, 2023

The pleasure is mine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants