You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by "Jarek Gawor (JIRA)" <ji...@apache.org> on 2009/02/10 02:35:00 UTC

[jira] Issue Comment Edited: (GERONIMO-4525) No effective exit code for all Windows commands

    [ https://issues.apache.org/jira/browse/GERONIMO-4525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12672104#action_12672104 ] 

gawor@mcs.anl.gov edited comment on GERONIMO-4525 at 2/9/09 5:33 PM:
---------------------------------------------------------------

Here's a simple batch and Java code that I used to experiment to whether resetting ERRORLEVEL to 0 or calling is cmd /c exit /b %errorlevel%:

Test.java:
{code}
public class Test {

    public static void main(String [] args) throws Exception {
        System.out.println(args[0]);
        System.exit(Integer.parseInt(args[0]));
    }
}
{code}

Test.bat:
{code}
@echo off

@setlocal enableextensions

set foo=
echo %errorlevel%

java Test %1
echo %errorlevel%

@endlocal
echo %errorlevel%
{code}

Then when you execute Test.bat 0 or Test.bat 50 and check echo %ERRORLEVEL% after executing it you should see that the %ERRORLEVEL% is set to the right value without doing anything extra. So based on this I think resetting the ERRORLEVEL or calling  cmd /c exit /b %errorlevel%: at the end of the batch file is unnecessary. 


      was (Author: gawor@mcs.anl.gov):
    Here's a simple batch and Java code that I used to experiment to whether resetting ERRORLEVEL to 0 or calling is cmd /c exit /b %errorlevel%:

Test.java:
{code}
public class Test {

    public static void main(String [] args) throws Exception {
        System.out.println(args[0]);
        System.exit(Integer.parseInt(args[0]));
    }
}
{code}

Test.bat:
{code}
@echo off

@setlocal enableextensions

set foo=
echo %errorlevel%

java Test %1
echo %errorlevel%

@endlocal
echo %errorlevel%
{code}

Then when you execute Test.bat 0 or Test.bat 50 and check echo %ERRORLEVEL% after executing it you should see that the %ERRORLEVEL% is set to the right value without doing anything extra. 

  
> No effective exit code for all Windows commands
> -----------------------------------------------
>
>                 Key: GERONIMO-4525
>                 URL: https://issues.apache.org/jira/browse/GERONIMO-4525
>             Project: Geronimo
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: commands
>    Affects Versions: 2.1.3
>         Environment: MS Windows
>            Reporter: Jack Cai
>            Assignee: Jarek Gawor
>             Fix For: 2.1.4, 2.2
>
>         Attachments: Geronimo-4525_Jack.patch
>
>
> There are multiple problems in the current Windows batch commands (including geronimo.bat, startup.bat, etc.)
>  - It's not recommended to define an environment variable with the name ERRORLEVEL. See [1].
>  - Set a value to ERRORLEVEL has no effect to the exit code of the batch command (so the documented exit code "0" and "1" are not actually there).
>  - The value of the ERRORLEVEL variable will also get unset when the "@endlocal" command is called.
> [1] http://blogs.msdn.com/oldnewthing/archive/2008/09/26/8965755.aspx

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.