This is the mail archive of the
mailing list for the Cygwin project.
Re: cygwin bash include scripting and error code return question
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 Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple