Re: shell for-loop in make

"ElChino" <[email protected]> Thu, 23 Oct 2014 21:50:35 +0200
Newsgroups gmane.comp.gnu.utils
Organization A noiseless patient Spider
Message-ID <[email protected]>
"Bob Proulx" <[email protected]> wrote:
 
> If tee exits last then it will set the $? exit code.  I didn't try it
> but I think that is your problem.  I didn't try it so I could be wrong.

You were right.
 
> depend all clean distclean:
> rm -f make.log ; \
> for d in $(DIRS) ; do \
>   $(MAKE) -C $$d $@ ; \
>   if [ $$? -ne 0 ]; then \
>     echo "make failed with error $$?"; \
>     exit 1; \
>   fi; \
> done | tee -a make.log

I actually did this before I read your reply.
 
> Additionally that pwd save and cd restore was useless in the example
> you showed.

I don't know 'sh' that well. I imagined I had to push pop the directery.

Thanks for your help!