Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Aug 1999 09:04:50 +0100
From:      Roger Hardiman <roger@cs.strath.ac.uk>
To:        hackers@freebsd.org, luigi@freebsd.org, abial@freebsd.org
Subject:   Help with exit status in shell script
Message-ID:  <37C79822.D28CD168@cs.strath.ac.uk>

next in thread | raw e-mail | index | archive | help
Hi,
There is a bug in the PicoBSD build shell script in and I have no idea
how to fix it. As a result, build errors are not caught.
It is all to do with Exit Status of programs called from a shell script.
Please help.

The code fragment from /usr/src/release/picobsd/build/build is
   ./stage1 2>&1 | tee stage1.out
    if [ "X$?" != "X0" ] ; then 
        echo "^G"
        echo "-> ERROR in \"${i}\" script. Aborting the build process."
        exit 10
    fi

Build calls Stage1. Stage1 will return with an error code in some cases
and we want to trap this and halt the Build script.

   ./stage1 2>&1 | tee stage1.out
    if [ "X$?" != "X0" ] ; then 

Normally, $? will return the Exit Status of the last executed program.
However, due to the pipe through Tee, the Exit Status I get is the
exit status of Tee and not the exit status of the Stage1 script.

I still want to output the stage1 script to screen and a log file.
How can I do this and preserve the exit status for the Build script.

Thanks
Roger
--
Roger Hardiman
roger@freebsd.org


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?37C79822.D28CD168>