This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How do I detect a failure in Make?


Richard Quadling wrote:
I have the following bash script ...

#!/bin/sh
cvs up 2> $HOME/cvs1.log > $HOME/cvs2.log
cd phpdoc
autoconf -v -d --warnings=all &> $HOME/autoconf.log
./configure --with-source=./../php-src --with-pear-source=./../pear
--with-chm=yes --with-treesaving > $HOME/configure.log
make test > $HOME/make_test.log
[ $? -eq 0 ] || exit $?
make test_xml > $HOME/make_test_xml.log
[ $? -eq 0 ] || exit $?
make chm_xsl > $HOME/make_chm_xsl.log
[ $? -eq 0 ] || exit $?

Is there a way of stopping the makes if there was a problem.

(additions in-line)


You might want to try 'man bash'. Doing something based on the return status of a command is pretty basic. Also, TMTOWTDI:

if [ $? -ne 0 ] ; then exit $? ; fi
if [ $? -eq 0 ] ; then : ; else exit $? ; fi
if ! make > log ; then exit $? ; fi
if make > log ; then : ; else exit $? ; fi
make > log || exit $?

Note that using 'exit $?' is good practice because it means your *script* will fail, which means you can embed your *script* like you've embedded 'make' and take action based on if it succeeds or fails (this is ALWAYS good practice in the pipe-biased environment of UNIX). However, be careful that you don't do something that replaces $? with the exit status of someone other than 'make' (in which case you should either save the status or 'exit <non-zero constant>').

--
Matthew
All of my signatures are 100% original. Including this one.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]