X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=an7q8k1+e/mEGYWWZPBJ5TVM1YKht7WLHOnQt2Doxb+2DKor2WFvp coBwqwZZ4hbqg/2XH2ax9Kc79rlc1f11TtOVvk58EcxQpgHGfAlzbq/FoviFvZ73 FKIxFnS6Ocur1H88jIgSf3i/AlS5YEiCscOm6URvB8MSAssDInlLn8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=RnezGa+aHDfokB5qssNItGnoXoY=; b=s6DrSTdpRwDfuXTFWKWely1GaziX GRXGdpyuAxGHCHXp/zhbge6Mrn/SwRqPYijS6nCBukEU8ruOGI9nFPjflehnpb55 LC24JKTxKaPZcjgSmSBj/7W1No+ZglrEtCmq7iXn3aAHLtd8gxmvX3fvI4fkzUXf z/HRUhOpbSXOygc= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: mho-01-ewr.mailhop.org X-Mail-Handler: Dyn Standard SMTP by Dyn X-Report-Abuse-To: abuse AT dyndns DOT com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1+oKG5ugvY6DVZ9Cf+g8zPw Date: Fri, 11 Oct 2013 11:53:27 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: ERRORLEVEL not returning to Cygwin shell Message-ID: <20131011155327.GA2240@ednor.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <5257FE1A DOT 5050905 AT cygwin DOT com> <0D835E9B9CD07F40A48423F80D3B5A7028690FDD AT USA7109MB022 DOT na DOT xerox DOT net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) 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