[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using if statement
From: |
Philip Guenther |
Subject: |
Re: using if statement |
Date: |
Fri, 4 May 2007 13:48:57 -0600 |
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