This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: ERRORLEVEL not returning to Cygwin shell
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 11 Oct 2013 11:53:27 -0400
- Subject: Re: ERRORLEVEL not returning to Cygwin shell
- Authentication-results: sourceware.org; auth=none
- References: <5257FE1A dot 5050905 at cygwin dot com> <0D835E9B9CD07F40A48423F80D3B5A7028690FDD at USA7109MB022 dot na dot xerox dot net> <CA+sc5mm2kJSZFDeQVcunqXw57FPfMcNsbp-sV4YUECHxfqd-gg at mail dot gmail dot com>
- Reply-to: cygwin at cygwin dot com
On Fri, Oct 11, 2013 at 10:42:47AM -0400, Earnie Boyd wrote:
>On Fri, Oct 11, 2013 at 10:35 AM, Nellis, Kenneth wrote:
>>> From: Larry Hall (Cygwin)
>>>
>>> On 10/11/2013 8:27 AM, paul hermeneutic wrote:
>>> > I am using CYGWIN_NT-5.1 PAC047922 1.7.25(0.270/5/3) 2013-08-31 20:39
>>> > i686 Cygwin
>>> >
>>> > An exit code returned by a DOS batch file does not seem to be coming
>>> > back to the Cygwin shell. I am using bash.
>>> >
>>> > $ cat myexit.bat
>>> > @echo off
>>> > set EXITCODE=%1
>>> > echo got here with %1
>>> > exit /b %EXITCODE%
>>> >
>>> > $ cmd /c c:/DOCUME~1/pwatson/bin/myexit.bat 8
>>> > got here with 8
>>> >
>>> > $ echo $?
>>> > 0
>>>
>>> WJFFM. Same version, same arch. Guess you need to do some more digging.
>>
>> FWIW, I get the same results as the OP:
>>
>> $ cat myexit.bat
>> @echo off
>> set EXITCODE=%1
>> echo got here with %1
>> exit /b %EXITCODE%
>> $ cmd /c myexit.bat 8
>> got here with 8
>> $ echo $?
>> 0
>> $ uname -r
>> 1.7.25(0.270/5/3)
>> $
>>
>> For grins, I tried with both Unix and DOS line endings. Made no difference.
>
>Cygwin has no control and loses all communication with the cmd.exe
>child process. How is it supposed to return anything other than an
>exit code of 0 because cmd.exe exited normally. You simply cannot mix
>Windows and Cygwin like this.
exit /b seems to cause CMD to exit with that value. It does for me:
% cmd /c myexit.bat 9; echo SAW $?
got here with 9
SAW 9
This is on Windows 7 64. Maybe other versions of Windows differ.
cgf
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple