using /bin/sh in make commands

David Kuder david at indetech.com
Thu Oct 19 09:08:33 AEST 1989


In article <21173 at adm.BRL.MIL> Leisner.Henr at xerox.com (Marty) writes:
>Often people have rules in makefiles of the form:
foo:
	for i in $(DIRS); do \
		(cd $$i; $(MAKE) foo); \
	done

>It seems if one of the sub-makes fails, the shell loop  continues.
>The Bourne shell has a -e flag to exit immediately on errors.
>Unfortunately a line like:
SHELL=/bin/sh -e
>doesn't work.  (make tries to exec "/bin/sh -e").
>Is there a good way to get the functionality I'm looking for without having
>to hack up all the makefiles?


Which make are you using?  There are way too many of these beasts.
However, on the three that I have at hand, SunOS4, Sys5.3, UCB4.3 (the
last two are Pyramid versions), a "make foo" stops as soon as one of
the sub makes fails.

If you must avoid changing the makefile (arguably broken) if you run
the make under a Bourne in which a 'set -e' has been done then the
shells started by the make will inherit it.  I can't test this but
it may work.
-- 
David A. Kuder                              Comp.lang.perl, the time is now!
415 438-2003  david at indetech.com  {uunet,sun,sharkey,pacbell}!indetech!david



More information about the Comp.unix.wizards mailing list