public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* ERRORLEVEL not returning to Cygwin shell
@ 2013-10-11 12:25 paul.hermeneutic
  0 siblings, 0 replies; 8+ messages in thread
From: paul.hermeneutic @ 2013-10-11 12:25 UTC (permalink / raw)
  To: cygwin

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

--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ERRORLEVEL not returning to Cygwin shell
  2013-10-11 12:27 paul.hermeneutic
  2013-10-11 13:33 ` Larry Hall (Cygwin)
@ 2013-10-11 20:50 ` Andrey Repin
  1 sibling, 0 replies; 8+ messages in thread
From: Andrey Repin @ 2013-10-11 20:50 UTC (permalink / raw)
  To: paul.hermeneutic, cygwin

Greetings, paul.hermeneutic@gmail.com!

> 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

Carry this case to appropriate forums.

[C:\]$ cat test.bat
cmd.exe /C C:\testcase.bat
echo %ERRORLEVEL%

[C:\]$ cat testcase.bat
@exit /B 8

[C:\]$ test.bat
0

[C:\]$


--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 12.10.2013, <00:39>

Sorry for my terrible english...


--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ERRORLEVEL not returning to Cygwin shell
  2013-10-11 15:53       ` Christopher Faylor
@ 2013-10-11 17:24         ` Larry Hall (Cygwin)
  0 siblings, 0 replies; 8+ messages in thread
From: Larry Hall (Cygwin) @ 2013-10-11 17:24 UTC (permalink / raw)
  To: cygwin

On 10/11/2013 11:53 AM, Christopher Faylor wrote:
> 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.

Don't know if it's significant or not but I'm running W7 64 too,
running Cygwin 32bit.


-- 
Larry

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ERRORLEVEL not returning to Cygwin shell
  2013-10-11 14:42     ` Earnie Boyd
@ 2013-10-11 15:53       ` Christopher Faylor
  2013-10-11 17:24         ` Larry Hall (Cygwin)
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Faylor @ 2013-10-11 15:53 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ERRORLEVEL not returning to Cygwin shell
  2013-10-11 14:36   ` Nellis, Kenneth
@ 2013-10-11 14:42     ` Earnie Boyd
  2013-10-11 15:53       ` Christopher Faylor
  0 siblings, 1 reply; 8+ messages in thread
From: Earnie Boyd @ 2013-10-11 14:42 UTC (permalink / raw)
  To: cygwin

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.

-- 
Earnie
-- https://sites.google.com/site/earnieboyd

--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: ERRORLEVEL not returning to Cygwin shell
  2013-10-11 13:33 ` Larry Hall (Cygwin)
@ 2013-10-11 14:36   ` Nellis, Kenneth
  2013-10-11 14:42     ` Earnie Boyd
  0 siblings, 1 reply; 8+ messages in thread
From: Nellis, Kenneth @ 2013-10-11 14:36 UTC (permalink / raw)
  To: cygwin

> 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.

--Ken Nellis

--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ERRORLEVEL not returning to Cygwin shell
  2013-10-11 12:27 paul.hermeneutic
@ 2013-10-11 13:33 ` Larry Hall (Cygwin)
  2013-10-11 14:36   ` Nellis, Kenneth
  2013-10-11 20:50 ` Andrey Repin
  1 sibling, 1 reply; 8+ messages in thread
From: Larry Hall (Cygwin) @ 2013-10-11 13:33 UTC (permalink / raw)
  To: cygwin

On 10/11/2013 8:27 AM, paul.hermeneutic@gmail.com 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.


-- 
Larry

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* ERRORLEVEL not returning to Cygwin shell
@ 2013-10-11 12:27 paul.hermeneutic
  2013-10-11 13:33 ` Larry Hall (Cygwin)
  2013-10-11 20:50 ` Andrey Repin
  0 siblings, 2 replies; 8+ messages in thread
From: paul.hermeneutic @ 2013-10-11 12:27 UTC (permalink / raw)
  To: cygwin

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

--
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-10-11 20:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-11 12:25 ERRORLEVEL not returning to Cygwin shell paul.hermeneutic
2013-10-11 12:27 paul.hermeneutic
2013-10-11 13:33 ` Larry Hall (Cygwin)
2013-10-11 14:36   ` Nellis, Kenneth
2013-10-11 14:42     ` Earnie Boyd
2013-10-11 15:53       ` Christopher Faylor
2013-10-11 17:24         ` Larry Hall (Cygwin)
2013-10-11 20:50 ` Andrey Repin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).