delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/03/25/20:46:23

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4F6FBC46.30707@tlinx.org>
Date: Sun, 25 Mar 2012 17:45:58 -0700
From: Linda Walsh <cygwin AT tlinx DOT org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666
MIME-Version: 1.0
To: John Fairhall <john AT utilibill DOT com DOT au>,
"cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Re: cygwin bash include scripting and error code return question
References: <3B35330F74CE0544934D0AAC1FBF7AFD019D01 AT AMSPRD0702MB120 DOT eurprd07 DOT prod DOT outlook DOT com>
In-Reply-To: <3B35330F74CE0544934D0AAC1FBF7AFD019D01@AMSPRD0702MB120.eurprd07.prod.outlook.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

John Fairhall wrote:

> Hi,
> 
> I have a cygwin bash script running on 32 bit XP.
> 
> I have a windows BAT script calling bash, like so:
> 
> -------------------
> bash mainScript.sh 2>&1 | tee %LOGFILE%
> bash mailBuild.sh %ERRORLEVEL% %LOGFILE%
> -------------------
> 
> 
> What I was hoping was that bash would propagate the shell script's return code to the external OS, but as far as I can see the windows ERRORLEVEL is always 0.
> 
> Is there a way to make bash do this?

----
	Question -- is %ERRORLEVEL% returning the value of bash or the value of 'tee'? 
   I am guessing it returns the value of 'tee'.

If you want to do what you are doing...um...

   bash -o pipefail -c "mainScript.sh  >| tee %LOGFILE%"



should do it...

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019