X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Mon, 26 Mar 2012 12:26:20 +0200
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: cygwin bash include scripting and error code return question
Message-ID: <20120326102620.GN2425@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <3B35330F74CE0544934D0AAC1FBF7AFD019D01@AMSPRD0702MB120.eurprd07.prod.outlook.com> <4F6FBC46.30707@tlinx.org> <3B35330F74CE0544934D0AAC1FBF7AFD01A8CB@AMSPRD0702MB120.eurprd07.prod.outlook.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <3B35330F74CE0544934D0AAC1FBF7AFD01A8CB@AMSPRD0702MB120.eurprd07.prod.outlook.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Mar 26 05:24, John Fairhall wrote:
> The pipe is definitely the problem.
> 
> If I have this:
> 
> bash mainScript.sh 2>&1
> bash mailBuild.sh %ERRORLEVEL% %LOGFILE%
> 
> When I gimmick mainScript to exit with any non-zero value I get an ERRORLEVEL of 255.
> 
> However, when I do this:
> 
> bash -o pipefail mainScript.sh 2>&1 | tee $LOGFILE bash mailBuild.sh %ERRORLEVEL% %LOGFILE%
> 
> I always get a zero ERRORLEVEL.

Sure.  Consider that the pipe is not created by bash, but by cmd.  What
you get is the exitcode of the last command in the pipe, which is tee.

> When I try this:
> 
> bash -o pipefail -c "mainScript.sh  2>&1 | tee %LOGFILE%"
> it errors with
> bash: mainScript.sh: command not found

Sure.  You're using the -c option, so you're trying to run mainScript.sh
as a command.  I assume mainScript.sh is in the current working
directory.  And the current working directory is not in $PATH.  And it
shouldn't.  Either use ./mainScript.sh or, better, the full path to
mainScript.sh since that makes you independent of your CWD.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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

