[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using if statement
From: |
Satish Somasundaram |
Subject: |
Re: using if statement |
Date: |
Sat, 5 May 2007 15:28:51 +0530 |
Hi all,
thanks for your help. The fix by Philip works like a charm.
I had issues with making 'make' recogonize, $?. I guess it should have been $$? :)
Thanks a lot.
-Satish
On 5/5/07, Philip Guenther <address@hidden> wrote:
On 5/4/07, Eli Zaretskii <address@hidden> wrote:
> From: "Satish Somasundaram" <
address@hidden>
...
> > for dir in `$(SUB_DIRS)`; do \
> > $(MAKE) -C $$dir; \
> > done
>
> Does the following (100% untested) modification work?
>
> for dir in `$(SUB_DIRS)`; do \
> $(MAKE) -C $$dir || (echo "ERROR" && exit 1); \
> done
So close... By wrapping the echo and exit in parens, you force them
to be performed by a subshell, so the exit doesn't affect the parent
shell which make is watching. You need to either use braces instead
of parens or leave out the echo.
i.e., leaving out the echo:
for dir in `$(SUB_DIRS)`; do \
$(MAKE) -C $$dir || exit $$?; \
done
(note: $$? will be expanded by make to $?, which the shell will then
expand to the exit status of the previous command)
vs using braces:
for dir in `$(SUB_DIRS)`; do \
$(MAKE) -C $$dir || { echo "ERROR" && exit 1; } \
done
(Yes, the semicolon before the close brace is required, as braces are
"reserved words" and not "meta-characters" for the shell...)
Personally, I prefer the "no echo and no braces" version, as make is
noisy enough about the non-zero exit as is.
Philip Guenther