You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "John Casey (JIRA)" <ji...@codehaus.org> on 2008/02/06 20:07:28 UTC

[jira] Closed: (MNG-3296) mvn.bat looses error code on windows NT type platforms

     [ http://jira.codehaus.org/browse/MNG-3296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Casey closed MNG-3296.
---------------------------

    Resolution: Fixed

applied the fix in the description. Thanks.

Incidentally, I don't have a copy of windows here, so if someone could try this and reopen it if it doesn't work, I'd appreciate it!

> mvn.bat looses error code on windows NT type platforms
> ------------------------------------------------------
>
>                 Key: MNG-3296
>                 URL: http://jira.codehaus.org/browse/MNG-3296
>             Project: Maven 2
>          Issue Type: Bug
>          Components: Command Line
>    Affects Versions: 2.0.7
>            Reporter: Matthias Kerkhoff
>            Assignee: John Casey
>             Fix For: 2.0.9, 2.1-alpha-1
>
>
> There is a bug in the mvn.bat script that prevents that an error code is properly returned to the caller of the script. 
> The batch script executes the following lines after maven has been invoked if an error occurs:
> if ERRORLEVEL 1 goto error 
> :error
> set ERROR_CODE=1
> :end
> if "%OS%"=="Windows_NT" goto endNT
> :endNT
> @endlocal
> if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
> if "%MAVEN_BATCH_PAUSE%" == "on" pause
> if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
> exit /B %ERROR_CODE%
> The problem is the endlocal statement. Calling endlocal ends the scope in which ERROR_CODE was set to 1. The previous value of ERROR_CODE will be reinstantiated (which is always 0, see line 46).
> To fix the problem make the ERROR_CODE value known in the outer ("global") scope by changing the endlocal statement into
> @endlocal & set ERROR_CODE=%ERROR_CODE%

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira